First push.

This commit is contained in:
BoHung Chiu 2022-05-23 18:32:51 +08:00
commit 8ad75cad48
100 changed files with 8427 additions and 0 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/db/*.sqlite3-journal
test/dummy/log/*.log
test/dummy/tmp/
test/dummy/.sass-cache

14
Gemfile Normal file
View File

@ -0,0 +1,14 @@
source "https://rubygems.org"
# Declare your gem's dependencies in bulletin.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.
# To use debugger
# gem 'debugger'

106
Gemfile.lock Normal file
View File

@ -0,0 +1,106 @@
PATH
remote: .
specs:
coloncancerpredict1 (0.0.1)
mongoid (= 4.0.0.beta1)
rails (~> 4.1.0.rc2)
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.1.0.rc2)
actionpack (= 4.1.0.rc2)
actionview (= 4.1.0.rc2)
mail (~> 2.5.4)
actionpack (4.1.0.rc2)
actionview (= 4.1.0.rc2)
activesupport (= 4.1.0.rc2)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.1.0.rc2)
activesupport (= 4.1.0.rc2)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.0.rc2)
activesupport (= 4.1.0.rc2)
builder (~> 3.1)
activerecord (4.1.0.rc2)
activemodel (= 4.1.0.rc2)
activesupport (= 4.1.0.rc2)
arel (~> 5.0.0)
activesupport (4.1.0.rc2)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
arel (5.0.0)
atomic (1.1.16)
bson (2.2.1)
builder (3.2.2)
connection_pool (2.0.0)
erubis (2.7.0)
hike (1.2.3)
i18n (0.6.9)
json (1.8.1)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
minitest (5.3.1)
mongoid (4.0.0.beta1)
activemodel (>= 4.0.0)
moped (~> 2.0.beta6)
origin (~> 2.1)
tzinfo (>= 0.3.37)
moped (2.0.0.rc1)
bson (~> 2.2)
connection_pool (~> 2.0)
optionable (~> 0.2.0)
multi_json (1.9.2)
optionable (0.2.0)
origin (2.1.1)
polyglot (0.3.4)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.1.0.rc2)
actionmailer (= 4.1.0.rc2)
actionpack (= 4.1.0.rc2)
actionview (= 4.1.0.rc2)
activemodel (= 4.1.0.rc2)
activerecord (= 4.1.0.rc2)
activesupport (= 4.1.0.rc2)
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.0.rc2)
sprockets-rails (~> 2.0.0)
railties (4.1.0.rc2)
actionpack (= 4.1.0.rc2)
activesupport (= 4.1.0.rc2)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.3)
sprockets (2.12.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
thor (0.19.1)
thread_safe (0.3.1)
atomic (>= 1.1.7, < 2)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (1.1.0)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
coloncancerpredict1!

20
MIT-LICENSE Normal file
View File

@ -0,0 +1,20 @@
Copyright 2019 YOURNAME
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3
README.rdoc Normal file
View File

@ -0,0 +1,3 @@
= ColonCancerPredict1
This project rocks and uses MIT-LICENSE.

32
Rakefile Normal file
View File

@ -0,0 +1,32 @@
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'coloncancerpredict1'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task default: :test

Binary file not shown.

After

Width:  |  Height:  |  Size: 992 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

View File

@ -0,0 +1,841 @@
Array.prototype.get_nearest_value = function(goal){
var nearest_value = this.reduce(function(prev, curr) {
return (Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev);
});
return nearest_value;
}
function change_object_variables(obj1,obj2,operator="-",target="new"){
var obj_new = {};
var obj_keys = Object.keys(obj1);
obj_keys.forEach(function(k){
if(obj2[k] == undefined){
if( target == "new"){
obj_new[k] = obj1[k];
}
}else{
if(operator == "-"){
if( target == "new"){
obj_new[k] = obj1[k] - obj2[k];
}else{
obj1[k] = obj1[k] - obj2[k];
}
}else if(operator == "+"){
if( target == "new"){
obj_new[k] = obj1[k] + obj2[k];
}else{
obj1[k] = obj1[k] + obj2[k];
}
}
}
})
if( target == "new"){
return obj_new;
}else{
return obj1;
}
}
$(document).ready(function(){
var head_data = $.post("/coloncancerpredict1Result",{"header":1,locale:I18n.locale});
var data = {};
if(I18n.locale == 'en'){
var window_width = $(window).width();
if(window_width < 520){
$('#cancer_table .cencer_table_name').css('max-width','');
}else if(window_width < 768){
$('#cancer_table .cencer_table_name').css({'max-width':'','width':'11em'});
}else if(window_width < 860){
$('#cancer_table .cencer_table_name').css('max-width','30%');
}else if(window_width < 1130){
$('#cancer_table .cencer_table_name').css('max-width','33%');
}else{
$('#cancer_table .cencer_table_name').css('max-width','39%');
};
};
function round(num,Digit=0){
return Math.round(Number(num)*(10**Digit))/(10**Digit);
};
head_data.done(function(){
if(head_data.responseJSON['head_images'] != ''){
$('.header-nav').html(head_data.responseJSON['head_images']);
}
if(head_data.responseJSON['title'] != ''){
$('.navbar-brand').html(head_data.responseJSON['title']);
}
data['danger_texts'] = head_data.responseJSON['danger_texts'];
$('head title').text(head_data.responseJSON['page_title'])
});
var mapping_data = $.post("/coloncancerpredict1Result",{"get_mapping_data_from_csv":1,locale:I18n.locale});
mapping_data.done(function(){
// $('.header-nav').html(head_images.responseJSON['head_images']);
// $('.navbar-brand').html(head_images.responseJSON['title'])
window.mapping_data_from_csv = mapping_data.responseJSON['mapping_data_from_csv'];
});
Array.prototype.remove_item_from_array = function(){
var result_array = this;
for(var i=0;i<arguments.length;i++){
if(Array.isArray(arguments[i])){
for(var j=0;j<arguments.length;j++){
var index = result_array.indexOf(arguments[i][j]);
if(index == -1)
continue;
else{
result_array = result_array.slice(0, index).concat(result_array.slice(index + 1, result_array.length));
}
}
}else{
var index = result_array.indexOf(arguments[i]);
if(index == -1)
continue;
else{
result_array = result_array.slice(0, index).concat(result_array.slice(index + 1, result_array.length));
};
};
};
result_array.push = this.push;
result_array.remove_item_from_array = this.remove_item_from_array;
return result_array;
};
$('input#lymph_nodes_examined').data('range_new' , $('input#lymph_nodes_examined').data('range'));
$('input#lymph_nodes_positive').data('range_new' , $('input#lymph_nodes_positive').data('range'));
$('.num_only').on('input', function() {
$(this).siblings('.num_only_value').val($(this).val());
if( Number($(this).val()) < $(this).data('range')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range')[1] && $(this).data('range')[1] != undefined) ){
$(this).css('color','#f24a69');
$(this).addClass('cancertable_empty');
}else{
$(this).css('color','#333');
$(this).removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
$('input#lymph_nodes_positive').off('input').on('input',function(){
$(this).siblings('.num_only_value').val($(this).val());
if( Number($(this).val()) < $(this).data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range_new')[1] && $(this).data('range_new')[1] != undefined) ){
$(this).css('color','#f24a69');
$(this).addClass('cancertable_empty');
}else{
$(this).css('color','#333');
$(this).removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
$('input#lymph_nodes_examined').off('input').on('input',function(){
$(this).siblings('.num_only_value').val($(this).val());
if( Number($(this).val()) < $(this).data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range_new')[1] && $(this).data('range_new')[1] != undefined) ){
$(this).css('color','#f24a69');
$(this).addClass('cancertable_empty');
}else{
$(this).css('color','#333');
$(this).removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
$('.cancer_help_btn').off("click").on('click',function(){
var modal_head = "";
try{ modal_head = $(this).parent().find(">label").html()}catch(e){};
var modal_body = "";
try{ modal_body = $(this).parent().find(">input.help_texts").attr('value')}catch(e){};
$('#show_help_modal').html("<div class='modal-dialog'><div class='modal-content'><div class='modal-header'><button type='button' aria-hidden='true' class='close'>×</button><h4 class='modal-title'>"+modal_head+"</h4>"+
"</div><div class='modal-body'>"+modal_body+"</div><div class='modal-footer'><button type='button' class='btn btn-default'>Close</button></div></div></div>")
$('#show_help_modal').modal('show');
$('#show_help_modal .close').off("click").on('click',function(){
$('#show_help_modal').modal('hide');
});
$('#show_help_modal .modal-footer button').off("click").on('click',function(){
$('#show_help_modal').modal('hide');
});
});
$('.btn-add').click(function(){
$(this).parent().find('.num_only').removeClass('cancertable_empty');
if($(this).parent().find('.num_only').val()!=""){
var input_value = Number($(this).parent().find('.num_only').val());
if(Array.isArray($(this).parent().find('.num_only').data('range'))){
var compare_value = $(this).parent().find('.num_only').data('range')[1];
if(compare_value != undefined){
if(input_value+1 <= Number(compare_value))
$(this).parent().find('.num_only').val(input_value+1);
else{
input_value = $(this).parent().find('.num_only').data('range')[0];
if(input_value != undefined)
$(this).parent().find('.num_only').val(input_value);
};
}else{
$(this).parent().find('.num_only').val(input_value+1);
};
compare_value = $(this).parent().find('.num_only').data('range')[0];
if(compare_value != undefined){
if($(this).parent().find('.num_only').val() >= compare_value){
$(this).parent().find('.num_only').removeClass('cancertable_empty');
$(this).parent().find('.num_only').css('color','#333');
};
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
}else{
$(this).parent().find('.num_only').removeClass('cancertable_empty');
$(this).parent().find('.num_only').css('color','#333');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
};
}else{
try{
var input_value = $(this).parent().find('.num_only').data('range')[0];
if(input_value != undefined)
$(this).parent().find('.num_only').val(input_value);
}catch(e){
$(this).parent().find('.num_only').val(0);
};
if($(this).parent().find('.num_only').val() != ""){
$(this).parent().find('.num_only').removeClass('cancertable_empty');
$(this).parent().find('.num_only').css('color','#333');
};
};
});
$('.btn-sub').click(function(){
if($(this).parent().find('.num_only').val()!=""){
var input_value = Number($(this).parent().find('.num_only').val());
if(Array.isArray($(this).parent().find('.num_only').data('range'))){
var compare_value = $(this).parent().find('.num_only').data('range')[0];
if(compare_value != undefined){
if(input_value-1 >= Number(compare_value))
$(this).parent().find('.num_only').val(input_value-1);
else{
input_value = $(this).parent().find('.num_only').data('range')[1];
if(input_value != undefined)
$(this).parent().find('.num_only').val(input_value);
};
}else{
$(this).parent().find('.num_only').val(input_value-1);
};
compare_value = $(this).parent().find('.num_only').data('range')[1];
if(compare_value != undefined){
if($(this).parent().find('.num_only').val() <= compare_value){
$(this).parent().find('.num_only').removeClass('cancertable_empty');
$(this).parent().find('.num_only').css('color','#333');
};
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
}else{
$(this).parent().find('.num_only').removeClass('cancertable_empty');
$(this).parent().find('.num_only').css('color','#333');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
};
}else{
try{
var input_value = $(this).parent().find('.num_only').data('range')[1];
if(input_value != undefined){
$(this).parent().find('.num_only').val(input_value);
}else{
input_value = $(this).parent().find('.num_only').data('range')[0];
if(input_value != undefined)
$(this).parent().find('.num_only').val(input_value);
}
}catch(e){
$(this).parent().find('.num_only').val(0);
};
if($(this).parent().find('.num_only').val() != ""){
$(this).parent().find('.num_only').removeClass('cancertable_empty');
$(this).parent().find('.num_only').css('color','#333');
};
};
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
});
$('.cancer_table_btn').off('click').on('click',function(){
var index = $(this).index()/2;
try{
$(this).parent().find('>input').attr('value',0);
$(this).parent().find('>input').eq(index).attr('value',1);
$(this).parent().find('>button').removeClass('active');
$(this).parent().removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
}catch(e){};
$(this).addClass('active');
});
$('#cancer_table_reset').click(function(){
$('.cancer_table_btn').removeClass('active');
$('.cancer-btn-group input').attr('value',0);
$('.num_only').val('');
$('.num_only_value').val('');
$('#cancer_table .cancer_form_field').removeClass('cancertable_empty');
$('#colon_cancer_predict1_result_block').css('display','none');
$('#danger_texts').remove();
$('select.select_num').val('');
});
function get_input_data(){
var flag;
flag = 1;
for(var i = 0;i < $('#cancer_table .cancer_form_field').length;i++){
if($('#cancer_table .cancer_form_field').eq(i).hasClass('num_only')){
if($('#cancer_table .cancer_form_field').eq(i).val()==""){
flag = 0;
$('#cancer_table .cancer_form_field').eq(i).addClass('cancertable_empty');
}else if($('#cancer_table .cancer_form_field').eq(i).val() != "" && !$('#cancer_table .cancer_form_field').eq(i).hasClass('cancertable_empty')){
$('#cancer_table .cancer_form_field').eq(i).removeClass('cancertable_empty');
};
}else{
if($('#cancer_table .cancer_form_field').eq(i).find('[value="1"]').length == 0){
flag = 0;
$('#cancer_table .cancer_form_field').eq(i).addClass('cancertable_empty');
}else{
$('#cancer_table .cancer_form_field').eq(i).removeClass('cancertable_empty');
}
};
};
if( Number($('input#lymph_nodes_examined').siblings('.num_only_value').val()) < Number($('input#lymph_nodes_positive').siblings('.num_only_value').val())){
$('input#lymph_nodes_positive').addClass('cancertable_empty');
$('input#lymph_nodes_positive').css('color','rgb(242, 74, 105)');
};
if($('.cancertable_empty').length != 0){
flag = 0;
($('#danger_texts').length == 0) ? $('#cancer_table_submit').parent().before('<a id="danger_texts" style="color:red;">'+data['danger_texts']+'</a>') : null;
$('#danger_texts').css('margin-left',$(window).width()/2-$('#danger_texts').width()/2);
}else{
$('#danger_texts').remove();
};
if(flag == 1){
var post_json= {};
for(var i = 0;i < $('#cancer_table .cancer_form_field').length;i++){
var name = $('#cancer_table .cancer_form_field').eq(i).attr('id')
if($('#cancer_table .cancer_form_field').eq(i).hasClass('num_only'))
post_json[name] = Number($('#cancer_table .cancer_form_field').eq(i).siblings('.num_only_value').val());
else{
var index = ($('#cancer_table .cancer_form_field').eq(i).find('[value="1"]').index()+1)/2;
post_json[name] = index;
};
};
if( post_json["ER_status"] == 2 && post_json["PR_status"] == 2 ){
$('#hormone_therapy .cancer_table_btn').attr('disabled','disabled');
$('[for="hormone_therapy"]').css('color','rgb(204, 204, 204)');
}else{
$('#hormone_therapy .cancer_table_btn').removeAttr('disabled');
$('[for="hormone_therapy"]').css('color','');
};
/*disable_condition start*/
/*disable_condition end*/
return post_json;
}else{
return null;
}
};
function set_result(result){
if(result.responseJSON.lpv != "error"){
$('#choice_fields .cancer_table_btn').removeClass('active');
var load_heml = $('#result_table_content').html(result.responseJSON.table);
load_heml.ready(function(){
$('#result_table_content .cancer_years').eq(-1).addClass('active');
for(var i = 0;i < $('#result_table_content .cancer_years').length;i++){
$('#result_table_content .cancer_years').eq(i).attr('index',i)
};
$('#result_table_content .cancer_years').off('click').on('click',function(){
try{
$(this).parent().find('.cancer_years').removeClass('active');
}catch(e){};
$(this).addClass('active');
$('#current_year').attr('index',$(this).attr('index'));
$('#current_year').attr('value',$(this).html());
$('#current_year').change();
});
});
load_heml = $('#result_text_content').html(result.responseJSON.texts);
load_heml.ready(function(){
$('#result_text_content .cancer_years').eq(-1).addClass('active');
for(var i = 0;i < $('#result_text_content .cancer_years').length;i++){
$('#result_text_content .cancer_years').eq(i).attr('index',i)
};
$('#current_year').off('change');
$('#result_text_content .cancer_years').off('click')
$('#result_text_content .cancer_years').click(function(){
try{
$(this).parent().find('.cancer_years').removeClass('active');
}catch(e){};
$(this).addClass('active');
$('#current_year').attr('value',$(this).html());
$('#current_year').attr('index',$(this).attr('index'));
$('.surgery_year').html($(this).html());
$('#current_year').change();
});
$('#cancer_table_right_result .cancer-btn-group .cancer_table_btn').removeClass('active');
$('#cancer_table_right_result .cancer-btn-group >input').attr('value',"0");
for(var i = 0;i < $('#cancer_table_left_result .cancer-btn-group').length;i++){
$('#cancer_table_left_result .cancer-btn-group').eq(i).find('.cancer_table_btn').eq(0).addClass('active');
$('#cancer_table_left_result .cancer-btn-group').eq(i).find('>input').eq(0).attr('value',"1");
};
for(var i = 0;i < $('#cancer_table_right_result .cancer-btn-group').length;i++){
$('#cancer_table_right_result .cancer-btn-group').eq(i).find('.cancer_table_btn').eq(0).addClass('active');
$('#cancer_table_right_result .cancer-btn-group').eq(i).find('>input').eq(0).attr('value',"1");
};
var treatment_method = result.responseJSON.treatment_method;
var treatment_method_active_indices = result.responseJSON.treatment_method_active_indices;
$('tr.'+treatment_method[0]).addClass('tr_show');
var servive_ratio_arr = [result.responseJSON.servive_ratio]
var yes = (I18n.locale=="zh_tw") ? "是" : "yes";
var year = $('#current_year').attr('value');
var active_treatment = ['Surgery_only'];
$('tr.'+active_treatment[0]+' .Overall_Survival').html(servive_ratio_arr[0]+'%');
$('span.'+active_treatment[0]+'.Overall_Survival').html(Math.round(servive_ratio_arr[0]));
$('#colon_cancer_predict1_result_block').css('display','block');
var lpv_real = [result.responseJSON['lpv_variable']];
var lpv = /*therapy_lpv start*/[0, -0.6693];/*therapy_lpv end*/;
var lpv_dict={};
var lpv_calc=/*lpv_calc_formula_start*/{"1":"Math.exp(-0.005433642)**Math.exp(lpv_current)","3":"Math.exp(-0.02357545)**Math.exp(lpv_current)","5":"Math.exp(-0.03637668)**Math.exp(lpv_current)"};/*lpv_calc_formula_end*/
active_treatment.push = function() {
if(arguments.length == 1){
var year = $('#current_year').attr('value');
console.log(lpv_real);
console.log(lpv_dict[arguments[0]])
var lpv_current = change_object_variables(lpv_real[lpv_real.length-1],{"lpv": lpv_dict[arguments[0]]},'+');
lpv_real.push(lpv_current);
lpv_current = lpv_current['lpv'];
var servive_ratio = round(eval(lpv_calc[year])*100,2);
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+'%');
$('tr.'+arguments[0]+' td.Additional_Benefit').html(round(benefit,2)+'%');
$('tr.'+arguments[0]).css('display','table-row');
$('tr.tr_show').eq(-1).after($('tr.'+arguments[0]));
$('tr.'+arguments[0]).addClass('tr_show');
if(this.length == 1){
$('.addition').css('display','inline-block');
$('#result_text_content .extra-text').css('display','inline-block');
}
var add_choices = this.slice(1,this.length);
add_choices.push(arguments[0]);
var add_choices_transform = [];
for(var i = 0;i<add_choices.length;i++){
add_choices_transform.push($('[for="'+add_choices[i]+'"]').html())
};
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)
add_choices_str += ((I18n.locale == 'en' ? ', and ': '以及')+add_choices_transform[add_choices_transform.length-1])
else
add_choices_str = add_choices_transform[0];
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('{{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('{{Additional_Benefit}}','</span><span class="'+arguments[0]+' Additional_Benefit">'+Math.round(benefit)+'</span><span>');
var new_text = '<p class="texts_show"><span>';
new_text += (extra_therapy_texts+'</span></p>');
$('#result_text_content .extra-text .texts_show').eq(-1).after(new_text)
return Array.prototype.push.apply(this, arguments);
}else{
return Array.prototype.push.apply(this, arguments);
}
};
active_treatment.remove_item_from_array = function(){
if(arguments.length == 1 && !Array.isArray(arguments[0])){
var index = this.indexOf(arguments[0])
var year = $('#current_year').attr('value');
if(index < this.length - 1){
for(var i = index + 1;i < this.length; i++){
change_object_variables(lpv_real[i] , {"lpv": lpv_dict[arguments[0]]} , '-' , 'self');
var lpv_current = lpv_real[i];
lpv_current = lpv_current['lpv'];
var servive_ratio = round(eval(lpv_calc[year])*100,2);
servive_ratio_arr[i] = servive_ratio;
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+'%');
$('.'+active_treatment[i]+'.Overall_Survival').html(Math.round(servive_ratio));
$('tr.'+active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
$('.'+active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
};
var add_choices = [];
for(var i = 1;i < this.length; i++){
if(i != index){
add_choices.push(this[i]);
var add_choices_transform = [];
for(var j = 0;j<add_choices.length;j++){
add_choices_transform.push($('[for="'+add_choices[j]+'"]').html())
};
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)
add_choices_str += ((I18n.locale == 'en' ? ', and ': '以及')+add_choices_transform[add_choices_transform.length-1])
else
add_choices_str = add_choices_transform[0];
$('.'+active_treatment[i]+'.choices').html(add_choices_str);
}
};
};
$('tr.'+arguments[0]+' td.Overall_Survival').html('-');
$('tr.'+arguments[0]+' td.Additional_Benefit').html('-');
$('tr.'+arguments[0]).css('display','none');
$('tr.'+arguments[0]).removeClass('tr_show');
$('span.'+arguments[0]).eq(0).parent().remove();
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]);
if(this.length == 2){
$('.addition').css('display','none');
$('#result_text_content .extra-text').css('display','none');
};
return Array.prototype.remove_item_from_array.apply(this, arguments);
}else{
return Array.prototype.remove_item_from_array.apply(this, arguments);
};
};
for(var i = 0;i<treatment_method.length;i++){
lpv_dict[treatment_method[i]] = lpv[i];
var click_flag=false;
$('#'+treatment_method[i]+' .cancer_table_btn').off('click').click(function(){
var index = $(this).index()/2;
try{
$(this).parent().find('>input').attr('value',0);
$(this).parent().find('>input').eq(index).attr('value',1);
$(this).parent().find('>button').removeClass('active');
$(this).parent().removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
}catch(e){};
$(this).addClass('active');
if(!click_flag){
if(active_treatment.includes($(this).parent().attr('id'))){
click_flag = true;
active_treatment = active_treatment.remove_item_from_array($(this).parent().attr('id'));
click_flag = false;
};
};
});
$('#'+treatment_method[i]+' .cancer_table_btn').eq(treatment_method_active_indices[i]).off('click').click(function(){
var index = $(this).index()/2;
try{
$(this).parent().find('>input').attr('value',0);
$(this).parent().find('>input').eq(index).attr('value',1);
$(this).parent().find('>button').removeClass('active');
$(this).parent().removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
}catch(e){};
$(this).addClass('active');
if(!click_flag){
if(!active_treatment.includes($(this).parent().attr('id'))){
click_flag = true;
active_treatment.push($(this).parent().attr('id'));
click_flag = false;
};
}
});
};
$('#current_year').change(function(){
year = $(this).attr('value');
$('.surgery_year').html(year);
$('.cancer_years').removeClass('active');
$('#result_text_content .cancer_years').eq($(this).attr("index")).addClass('active');
$('#result_table_content .cancer_years').eq($(this).attr("index")).addClass('active');
var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year}
calculate_and_change_result_value(obj);
servive_ratio_arr = obj.servive_ratio_arr;
active_treatment = obj.active_treatment;
lpv_real = obj.lpv_real;
lpv_calc = obj.lpv_calc;
year = obj.year;
});
$('#cancer_table .cancer_form_field').off('change').on('change',function(){
var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year}
after_submit_change_func(obj);
servive_ratio_arr = obj.servive_ratio_arr;
active_treatment = obj.active_treatment;
lpv_real = obj.lpv_real;
lpv_calc = obj.lpv_calc;
year = obj.year;
});
$('#cancer_table .cancer_form_field').click(function(){
$(this).change();
});
$('select.select_num').off('click').on('click',function(){
$(this).change();
var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year}
after_submit_change_func(obj);
servive_ratio_arr = obj.servive_ratio_arr;
active_treatment = obj.active_treatment;
lpv_real = obj.lpv_real;
lpv_calc = obj.lpv_calc;
year = obj.year;
});
$('.num_only').on('input', function() {
if( Number($(this).val()) < $(this).data('range')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range')[1] && $(this).data('range')[1] != undefined) ){
$(this).css('color','#f24a69');
$(this).addClass('cancertable_empty');
}else{
$(this).css('color','#333');
$(this).removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
var obj = {"servive_ratio_arr":servive_ratio_arr,"active_treatment":active_treatment,"lpv_real":lpv_real,"lpv_calc":lpv_calc,"year":year};
after_submit_change_func(obj);
servive_ratio_arr = obj.servive_ratio_arr;
active_treatment = obj.active_treatment;
lpv_real = obj.lpv_real;
lpv_calc = obj.lpv_calc;
year = obj.year;
};
});
});
};
};
function after_submit_change_func(obj){
var post_json = get_input_data();
if(post_json != null){
var new_lpv = calculate_first_lpv(post_json)['lpv_variable'];
var old_lpv = obj.lpv_real[0];
obj.lpv_real = obj.lpv_real.map(original_value=>(change_object_variables(original_value,change_object_variables(new_lpv,old_lpv,'-'),'+')));
calculate_and_change_result_value(obj);
};
};
/* auto add start */
function calculate_first_lpv(result_json){
result = {};
var map_values , mapping_hash , temp_index ,temp_value , index , closest_value;
result['age'] = Number(result_json['age']);
result['size'] = Number(result_json['size']);
result['lymph_nodes_examined'] = Number(result_json['lymph_nodes_examined']);
result['lymph_nodes_positive'] = Number(result_json['lymph_nodes_positive']);
result['grade'] = Number(result_json['grade']);
result['pstage'] = Number(result_json['pstage']);
result['Chemotherapy'] = Number(result_json['Chemotherapy']);
Object.keys(result).forEach(function(k){
if(Number.isNaN(result[k])){
result[k] = 0;
}
})
ratio = (result["lymph_nodes_examined"] == 0 ? 0 : (1.0 * result["lymph_nodes_positive"] / result["lymph_nodes_examined"]));
ratio = (ratio > 1 ? 1 : ratio);
nposit = ((ratio + 0.1) / 0.1) ** 0.5;
grade_1 = (result["grade"] == 1 || result["grade"] == 4) ? 1 : 0;
grade_2 = (result["grade"] == 2) ? 1 : 0;
grade_3 = (result["grade"] == 3) ? 1 : 0;
pstage_2 = (result["pstage"] == 2) ? 1 : 0;
pstage_3 = (result["pstage"] == 3) ? 1 : 0;
pstage_4 = (result["pstage"] == 4) ? 1 : 0;
chemo = (result["Chemotherapy"] == 2) ? 1 : 0;
try{
lpv = ((result["age"] - 62.31261) * (0.01385)+ (result["size"] - 45.85882)* (0.00786) + (nposit - 0.109264)* (1.83191) + grade_2*0.29793+grade_3*0.67389+pstage_2*1.1152+ pstage_3*2.2501+pstage_4*3.6206+chemo*(-0.6693)
)
}catch(e){console.log(e)};
result['lpv_variable'] = {};
result['lpv_variable']['lpv'] = lpv;
result['lpv'] = lpv;
result['lpv_variable']['lpv'] = result['lpv'];
return result;
};
function calculate_and_change_result_value(obj){
obj.servive_ratio_arr = [];
for(var i = 0;i<obj.active_treatment.length;i++){
var servive_ratio = round(calculate_servive_ratio(obj.year,obj.lpv_real[i])*100,2);
var benefit = servive_ratio - obj.servive_ratio_arr[obj.servive_ratio_arr.length-1];
obj.servive_ratio_arr.push(servive_ratio);
$('tr.'+obj.active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
$('.'+obj.active_treatment[i]+'.Overall_Survival').html(Math.round(servive_ratio));
if(i != 0){
$('tr.'+obj.active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
$('.'+obj.active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
}
}
//$('.'+obj.active_treatment[0]+'.Overall_Survival').html(Math.round(obj.servive_ratio_arr[0]));
};
function calculate_servive_ratio(year,obj){
var servive_ratio;
var lpv = obj['lpv'];
switch(year) {
case '1':
servive_ratio = Math.exp(-0.005433642)**Math.exp(lpv);
break;
case '3':
servive_ratio = Math.exp(-0.02357545)**Math.exp(lpv);
break;
case '5':
servive_ratio = Math.exp(-0.03637668)**Math.exp(lpv);
break;
default:
console.log('not found year.');
}
return servive_ratio;
}
/* auto add end */
function submit_fcn(){
var post_json = get_input_data();
if(post_json != null){
post_json['locale'] = I18n.locale;
var result = $.post("/coloncancerpredict1Result",{"data":post_json});
result.done(function(){
console.log(result.responseJSON);
set_result(result);
window.location.hash = '';
window.location.hash = '#colon_cancer_predict1_result_block';
});
};
};
$('#cancer_table_submit').click(function(){
submit_fcn();
});
for(var i = 0;i < $('.result_tab').length;i++){
$('.result_tab').eq(i).attr('index',i)
};
for(var i = 0;i < $('.result_content').length;i++){
$('.result_content').eq(i).attr('index',i)
};
$('.result_tab').click(function(){
var index = $(this).attr('index');
$('.result_tab').removeClass('active');
$(this).addClass('active');
$('.result_content').css('display','none');
$('.result_content[index="'+index+'"]').css('display','block');
})
$('.num_only').keypress(function(event){
return event.keyCode>=48&&event.keyCode<=57||(this.value.indexOf('.')<0?event.keyCode==46:false);
});
$('.float_num').off('keyup').on('keyup',function(){
this.value = this.value.replace(/[^\d.]/g,'');
});
$('.num_only').blur(function() {
if( Number($(this).val()) < $(this).data('range')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).data('range')[1] && $(this).data('range')[1] != undefined) ){
$(this).css('color','#f24a69');
$(this).addClass('cancertable_empty');
}else{
$(this).css('color','#333');
$(this).removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
$('select.select_num').off('click').on('click',function(){
$(this).change();
});
$('select.select_num').change(function(){
if(this.selectedIndex != 0){
$(this).siblings('input.num_only').val($(this).find('option').eq(this.selectedIndex).text());
$(this).siblings('input.num_only').removeClass('cancertable_empty');
$(this).siblings('input.num_only').css('color','#333');
}else{
$(this).siblings('input.num_only').addClass('cancertable_empty');
$(this).siblings('input.num_only').css('color','rgb(242, 74, 105)');
$(this).siblings('input.num_only').val($(this).val());
}
$(this).siblings('input.num_only_value').val($(this).val());
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
});
$('input#lymph_nodes_examined').siblings('select.select_num').off('change').on('change',function(){
var range = $('input#lymph_nodes_positive').data('range');
range[1] = Number($(this).val());
$('input#lymph_nodes_positive').data('range_new', range);
if(this.selectedIndex != 0){
$(this).siblings('input.num_only').val($(this).find('option').eq(this.selectedIndex).text());
$(this).siblings('input.num_only').removeClass('cancertable_empty');
$(this).siblings('input.num_only').css('color','#333');
}else{
$(this).siblings('input.num_only').addClass('cancertable_empty');
$(this).siblings('input.num_only').css('color','rgb(242, 74, 105)');
$(this).siblings('input.num_only').val($(this).val());
}
$(this).siblings('input.num_only_value').val($(this).val());
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
$(this).siblings('.num_only_value').val($(this).val());
if( Number($('input#lymph_nodes_positive').siblings('.num_only_value').val()) <= Number($(this).val()) ){
$('input#lymph_nodes_positive').css('color','#333');
$('input#lymph_nodes_positive').removeClass('cancertable_empty');
};
if( Number($(this).val()) < $(this).siblings('.num_only').data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).siblings('.num_only').data('range_new')[1] && $(this).siblings('.num_only').data('range_new')[1] != undefined) ){
$(this).siblings('.num_only').css('color','#f24a69');
$(this).siblings('.num_only').addClass('cancertable_empty');
}else{
$(this).siblings('.num_only').css('color','#333');
$(this).siblings('.num_only').removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
$('input#lymph_nodes_positive').siblings('select.select_num').off('change').on('change',function(){
var range = $('input#lymph_nodes_examined').data('range');
range[0] = Number($(this).val());
$('input#lymph_nodes_examined').data('range_new', range);
if(this.selectedIndex != 0){
$(this).siblings('input.num_only').val($(this).find('option').eq(this.selectedIndex).text());
$(this).siblings('input.num_only').removeClass('cancertable_empty');
$(this).siblings('input.num_only').css('color','#333');
}else{
$(this).siblings('input.num_only').addClass('cancertable_empty');
$(this).siblings('input.num_only').css('color','rgb(242, 74, 105)');
$(this).siblings('input.num_only').val($(this).val());
}
$(this).siblings('input.num_only_value').val($(this).val());
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
$(this).siblings('.num_only_value').val($(this).val());
if( Number($('input#lymph_nodes_examined').siblings('.num_only_value').val()) >= Number($(this).val()) ){
$('input#lymph_nodes_examined').css('color','#333');
$('input#lymph_nodes_examined').removeClass('cancertable_empty');
};
if( Number($(this).val()) < $(this).siblings('.num_only').data('range_new')[0] || $(this).val() == "" || (Number($(this).val()) > $(this).siblings('.num_only').data('range_new')[1] && $(this).siblings('.num_only').data('range_new')[1] != undefined) ){
$(this).siblings('.num_only').css('color','#f24a69');
$(this).siblings('.num_only').addClass('cancertable_empty');
}else{
$(this).siblings('.num_only').css('color','#333');
$(this).siblings('.num_only').removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
$('select.select_num').blur(function() {
if( Number($(this).siblings('.num_only_value').val()) < $(this).siblings('.num_only').data('range')[0] || $(this).siblings('.num_only_value').val() == "" || (Number($(this).siblings('.num_only_value').val()) > $(this).siblings('.num_only').data('range')[1] && $(this).siblings('.num_only').data('range')[1] != undefined) ){
$(this).siblings('.num_only').css('color','#f24a69');
$(this).siblings('.num_only').addClass('cancertable_empty');
}else{
$(this).siblings('.num_only').css('color','#333');
$(this).siblings('.num_only').removeClass('cancertable_empty');
if($('.cancertable_empty').length == 0){
$('#danger_texts').remove();
};
};
});
if($(window).width() < 768)
$('#colon_cancer_predict1_result').attr('style','');
});
$(window).resize(function(){
if($(window).width() > 768){
if($('.cancer_table_right_result').length != 0)
$('#colon_cancer_predict1_result').css('float','right');
}else{
$('#colon_cancer_predict1_result').attr('style','');
};
if(I18n.locale == 'en'){
var window_width = $(window).width();
if(window_width < 520){
$('#cancer_table .cencer_table_name').css('max-width','');
}else if(window_width < 768){
$('#cancer_table .cencer_table_name').css({'max-width':'','width':'11em'});
}else if(window_width < 860){
$('#cancer_table .cencer_table_name').css('max-width','30%');
}else if(window_width < 1130){
$('#cancer_table .cencer_table_name').css('max-width','33%');
}else{
$('#cancer_table .cencer_table_name').css('max-width','39%');
};
};
});

View File

@ -0,0 +1,3 @@
/*! SmartMenus jQuery Plugin Bootstrap Addon - v0.4.1 - September 17, 2017
* http://www.smartmenus.org/
* Copyright Vasil Dinkov, Vadikom Web Ltd. http://vadikom.com; Licensed MIT */(function(t){"function"==typeof define&&define.amd?define(["jquery","smartmenus"],t):"object"==typeof module&&"object"==typeof module.exports?module.exports=t(require("jquery")):t(jQuery)})(function(t){return t.extend(t.SmartMenus.Bootstrap={},{keydownFix:!1,init:function(){var e=t("ul.navbar-nav:not([data-sm-skip])");e.each(function(){function e(){o.find("a.current").parent().addClass("active"),o.find("a.has-submenu").each(function(){var e=t(this);e.is('[data-toggle="dropdown"]')&&e.dataSM("bs-data-toggle-dropdown",!0).removeAttr("data-toggle"),e.is('[role="button"]')&&e.dataSM("bs-role-button",!0).removeAttr("role")})}function s(){o.find("a.current").parent().removeClass("active"),o.find("a.has-submenu").each(function(){var e=t(this);e.dataSM("bs-data-toggle-dropdown")&&e.attr("data-toggle","dropdown").removeDataSM("bs-data-toggle-dropdown"),e.dataSM("bs-role-button")&&e.attr("role","button").removeDataSM("bs-role-button")})}function i(t){var e=a.getViewportWidth();if(e!=n||t){var s=o.find(".caret");a.isCollapsible()?(o.addClass("sm-collapsible"),o.is("[data-sm-skip-collapsible-behavior]")||s.addClass("navbar-toggle sub-arrow")):(o.removeClass("sm-collapsible"),o.is("[data-sm-skip-collapsible-behavior]")||s.removeClass("navbar-toggle sub-arrow")),n=e}}var o=t(this),a=o.data("smartmenus");if(!a){o.smartmenus({subMenusSubOffsetX:2,subMenusSubOffsetY:-6,subIndicators:!1,collapsibleShowFunction:null,collapsibleHideFunction:null,rightToLeftSubMenus:o.hasClass("navbar-right"),bottomToTopSubMenus:o.closest(".navbar").hasClass("navbar-fixed-bottom")}).on({"show.smapi":function(e,s){var i=t(s),o=i.dataSM("scroll-arrows");o&&o.css("background-color",t(document.body).css("background-color")),i.parent().addClass("open")},"hide.smapi":function(e,s){t(s).parent().removeClass("open")}}),e(),a=o.data("smartmenus"),a.isCollapsible=function(){return!/^(left|right)$/.test(this.$firstLink.parent().css("float"))&&"block"==this.$root.css("display")},a.refresh=function(){t.SmartMenus.prototype.refresh.call(this),e(),i(!0)},a.destroy=function(e){s(),t.SmartMenus.prototype.destroy.call(this,e)},o.is("[data-sm-skip-collapsible-behavior]")&&(a.opts.collapsibleBehavior="toggle");var n;i(),t(window).on("resize.smartmenus"+a.rootId,i)}}),e.length&&!t.SmartMenus.Bootstrap.keydownFix&&(t(document).off("keydown.bs.dropdown.data-api",".dropdown-menu"),t.fn.dropdown&&t.fn.dropdown.Constructor&&t(document).on("keydown.bs.dropdown.data-api",'.dropdown-menu:not([id^="sm-"])',t.fn.dropdown.Constructor.prototype.keydown),t.SmartMenus.Bootstrap.keydownFix=!0)}}),t(t.SmartMenus.Bootstrap.init),t});

File diff suppressed because one or more lines are too long

3132
app/assets/javascripts/react.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,88 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
thead > tr > th{
border:1px solid;
background: bisque;
}
tbody{
background:white;
}
tbody > tr > td{
border:1px solid;
position: relative;
}
.show_li,.show_li *{
list-style:none;
color:balck;
}
.show_li ul{
display:none;
}
#clicktosee{
color:blue;
cursor:pointer;
}
table .checkbox{
left: 50%;
position: absolute;
transform: translate(-50%, -50%) !important;
top: 50%;
}
#updatebtn{
margin-top: 1em;
right: 1em;
background-color: #0088cc;
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
}
.show_span{
margin: 1em;
float: left;
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
width: fit-content;
}
.label_left{
float: left;
padding-right: 0.5em;
}
.PageDetails {
padding-top: 0.1875em;
padding-bottom: 0.1875em;
font-weight: bold;
font-size: 0.875em;
border-bottom: 0.0625em solid #ddd;
overflow: hidden;
text-align: right;
color: black;
font-size: 1.3em;
}
.PageList {
margin: 0em 0em 0 0.5em;
font-weight: bold;
font-size: 0.875em;
overflow: hidden;
list-style: none;
display: inline;
background: none;
color: #999;
}
ol {
margin: 0 0 0.5em 0;
min-height: 0.625em;
height: auto !important;
height: 0.625em;
padding: 0;
clear: both;
float: right;
}
.PageList li {
display: inline;
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,392 @@
#cancer_table *[data-key]{
padding: 0.375em 0;
display: inline-block;
width: 100%;
}
.head_logo{
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){
.navbar-brand{
width: 100%;
}
}
div.num_group{
position: relative;
float: left;
width: 5.125em;
height: 2.25em;
margin-left: 1.125em;
}
@media screen and (min-width: 93.75em){
.navbar-brand>img.head_logo{
width: 50%;
height: auto;
}
}
@media screen and (min-width: 48.125em) and (max-width: 93.625em){
.navbar-brand>img.head_logo{
width: 70%;
height: auto;
}
}
.header-nav{
top:0 !important;
}
.title_texts{
color:rgb(210, 106, 2);
display:none;
}
.cencer_table_name{
display: inline-block;
vertical-align: middle;
color:#5d7ca2;
}
@media screen and (min-width: 71.125em){
#cancer_table .cencer_table_name{
width: 16.25em;
}
}
@media screen and (min-width: 28.375em) and (max-width: 71em){
#cancer_table .cencer_table_name{
width: 12.25em;
}
}
@media screen and (max-width: 28.25em){
#cancer_table .cencer_table_name{
width: 7em;
}
}
#colon_cancer_predict1_result_block .cencer_table_name{
width: 5em;
}
.cancer_table_btn{
margin-right: 0.5em;
color:#5d7ca2;
border-color: #5d7ca2;
font-weight: 600;
}
.cancer_table_btn::last-of-type{
margin-right:auto;
}
#cancer_table{
font-size:0.825em;
color:#5d7ca2;
}
#cancer_table_top{
padding-bottom: 4em;
}
#font_texts{
padding-right: 0.5em;
}
#text_describe{
font-weight: bold;
float: left;
max-width: 75%;
padding-bottom: 3em;
}
#font_size_choices{
font-weight: bold;
float: right;
max-width: 50%;
padding-left:1em;
}
form.for_num{
position: relative;
float:left;
}
select.select_num{
position: absolute;
width: 4.3em;
height: 1.75em;
left: 0em;
clip: rect(0.25em, 4.3em, 1.5em,3.3em);
border:none;
padding: 0.5em;
}
input.num_only{
margin-left: 0;
color: black;
border-top: 0.125em solid rgb(221, 221, 221);
width: 5.125em;
padding: 0em 0em 0.25em;
border-left: 0.125em solid rgb(221, 221, 221);
text-align: center;
font-size: 0.875em;
background-color: rgb(255, 255, 255);
height: 2.25em;
position: absolute;
left: 0;
}
input.float_num{
position: relative;
}
#cancer_table_left{
width:100%;
}
#cancer_table_right{
width:100%;
}
#cancer_table_submit{
margin-left: 1em;
float: right;
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
}
#cancer_table_reset{
float: right;
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
}
.btn-sub{
background:url("/assets/coloncancerpredict1/triangle_sub.png") no-repeat top transparent;
position: relative;
width: 1.875em;
border: 0;
height: 1.875em;
background-size: contain;
top:1em;
bottom: -0.7em;
padding: 0;
}
.btn-add{
background:url("/assets/coloncancerpredict1/triangle_add.png") no-repeat top transparent;
position: relative;
width: 1.875em;
border: 0;
height: 1.875em;
background-size: contain;
right: 1.815em;
top: -0.3em;
padding: 0;
}
.cancer_table_btn:focus{
color: #5d7ca2 !important;
background-color: #9dc3e6 !important;
border-color: #8c8c8c !important;
}
.cancer_table_btn:hover{
color: #5d7ca2 !important;
background-color: #9dc3e6 !important;
border-color: #8c8c8c !important;
}
.cancer_table_btn.active{
color: #5d7ca2;
background-color: #9dc3e6;
border-color: #8c8c8c;
}
.cancertable_empty{
border: 0.25em solid pink !important;
border-radius: 0.5em !important;
padding: 0.125em !important;
}
.result_title{
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
float: left;
}
.result_tab{
background: #023d79;
background: linear-gradient(135deg, transparent 0.3em, #023d79 0);
border: none;
float:right;
padding: 0.5em 0.125em 0.5em 0.5em;
margin-top: 0.5em;
cursor: pointer;
}
#cancer_table a:hover{
text-decoration: none;
color: #5d7ca2;
}
#result_contents{
padding-top: 1em;
}
#choice_fields{
padding: 2em 0 0 calc(20% - 1.625em);
}
.result_tab:hover{
background: #d16801;
background: linear-gradient(135deg, transparent 0.3em, #d16801 0);
padding: 0.8em 0.125em 0.5em 1em;
margin-left: -0.5em;
}
.result_tab.active{
background: #d16801;
background: linear-gradient(135deg, transparent 0.3em, #d16801 0);
padding: 0.8em 0.125em 0.5em 1em;
margin-left: -0.5em;
}
.result_tab > a{
writing-mode: vertical-lr;
-webkit-writing-mode: vertical-lr;
color: white;
}
.result_tab_group{
width: 15%;
margin: 0;
float: left;
}
.result_content_group{
width: 85%;
margin: 0;
float: right;
}
.result_content{
display: none;
min-height: 25em;
border: 0.125em solid #c0cbdd;
padding: 0.5em;
}
.result_content:first-of-type{
display: block;
}
.result_content a{
color: #5d7ca2;
}
.result_content p{
color: #5d7ca2;
clear: both;
}
.cancer_years{
float:left;
color: #5d7ca2;
background-color: #fff;
border-color: #5d7ca2;
border-width: 0.125em;
margin: 0em;
}
.cancer_years:first-of-type{
margin-left: 1em;
}
.cancer_years:last-of-type{
margin-right: 1em;
}
.cancer_form_field{
margin-left: 1em;
}
#result_table_content a{
float:left;
display: contents;
}
.result_content span{
color: #5d7ca2;
}
.hint-texts{
color: rgb(104, 104, 104);
font-size: 0.75em;
clear: both;
padding: 0.5em 0;
}
#result_text_content a{
float:left;
}
#result_table_content table{
clear: both;
width:100%;
table-layout: fixed;
overflow-wrap: break-word;
}
#result_table_content table tbody tr{
display: none;
}
#result_table_content table tbody tr:first-of-type{
display: table-row;
}
.white_text,.white_text:link,.white_text:visited{
color:white;
}
.cancer_th{
color: white;
background-color: #003d79;
border-right: 0.375em solid white;
border-top: 0.375em solid white;
}
.cancer_td {
background-color: #e9eaf5;
border-right: 0.375em solid white;
border-top: 0.375em solid white;
}
#colon_cancer_predict1_result_block{
display:none;
font-size: 0.825em;
margin-top: 3em;
border-top: #666 solid;
padding-top: 2em;
}
p.texts_show{
display: list-item;
margin-left: 1.5em;
clear: both;
}
div.texts_show{
display: block;
margin-left: 0;
}
.addition{
display: none;
}
#cancer_table_right_result .cancer_table_btn{
padding: 0.25em 1em;
}
#cancer_table_left_result .cancer_table_btn{
padding: 0.25em 1em;
}
.modal-dialog {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%) !important;
overflow: auto;
overflow-y: auto;
}
#colon_cancer_predict1_result{
width: 80%;
}
@media screen and (min-width: 48em) {
#cancer_table_right{
float:right;
width:50%;
}
#cancer_table_left{
float:left;
width:50%;
}
#cancer_table_right_result{
width: 50%;
float: right;
}
#cancer_table_left_result{
width: 50%;
float: left;
}
#colon_cancer_predict1_result{
width: 50%;
float: left;
}
.result_title{
margin-top: 1em;
}
}
.print_only{
display: none;
}

View File

@ -0,0 +1,402 @@
@import url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css);
button, input, optgroup, select, textarea {
margin: 0;
font: inherit;
color: inherit;
}
.fa {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
transform: translate(0, 0);
}
.fa-question:before {
content: "\f128";
}
button {
overflow: visible;
}
button, input, select, textarea {
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
#cancer_table *[data-key]{
padding: 0.375em 0;
display: inline-block;
width: 100%;
}
.head_logo{
height: 4em;
}
.texts_under_result{
font-weight: bold;
padding-top: 1em;
color: #5d7ca2;
}
th.cancer_th.Treatment {
width: 39%;
}
div.num_group{
position: relative;
float: left;
width: 5.125em;
height: 2.25em;
margin-left: 1.125em;
}
.navbar-brand>img.head_logo{
width: 70%;
height: auto;
}
.header-nav{
top:0 !important;
}
.title_texts{
color:rgb(210, 106, 2);
display:none;
}
.cencer_table_name{
display: inline-block;
vertical-align: middle;
color:#5d7ca2 !important;
}
#cancer_table .cencer_table_name{
width: 16.25em;
}
#colon_cancer_predict1_result_block .cencer_table_name{
width: 5em;
}
.cancer_help_btn{
background-color: rgb(210, 106, 2) !important;
border-color: rgb(210, 106, 2) !important;
color: white !important;
}
.cancer_help_btn i:before {
color: white !important;
}
.cancer_table_btn{
margin-right: 0.5em;
color:#5d7ca2 !important;
border-color: #5d7ca2 !important;
font-weight: 600;
}
.cancer_table_btn::last-of-type{
margin-right:auto;
}
#cancer_table{
font-size:0.825em;
color:#5d7ca2;
}
@media print{
#cancer_table_top{
padding-bottom: 4em;
}
#font_texts{
padding-right: 0.5em;
}
#text_describe{
font-weight: bold;
float: left;
max-width: 75%;
padding-bottom: 3em;
}
#font_size_choices{
font-weight: bold;
float: right;
max-width: 50%;
padding-left:1em;
}
form.for_num{
position: relative;
float:left;
}
select.select_num{
position: absolute;
width: 4.3em;
height: 1.75em;
left: 0em;
clip: rect(0.25em, 4.3em, 1.5em,3.3em);
border:none;
padding: 0.5em;
}
input.num_only{
margin-left: 0;
color: black;
border-top: 0.125em solid rgb(221, 221, 221);
width: 5.125em;
padding: 0em 0em 0.25em;
border-left: 0.125em solid rgb(221, 221, 221);
text-align: center;
font-size: 0.875em;
background-color: rgb(255, 255, 255) !important;
height: 2.25em;
position: absolute;
left: 0;
}
input.float_num{
position: relative;
}
#cancer_table_left{
width:100%;
}
#cancer_table_right{
width:100%;
}
#cancer_table_submit{
margin-left: 1em;
float: right;
background-color: rgb(210, 105, 0) !important;
color: white !important;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
}
#cancer_table_reset{
float: right;
background-color: rgb(210, 105, 0) !important;
color: white !important;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
}
.btn-sub{
background:url("/assets/coloncancerpredict1/triangle_sub.png") no-repeat top transparent;
position: relative;
width: 1.875em;
border: 0;
height: 1.875em;
background-size: contain;
top:1em;
bottom: -0.7em;
padding: 0;
}
.btn-add{
background:url("/assets/coloncancerpredict1/triangle_add.png") no-repeat top transparent;
position: relative;
width: 1.875em;
border: 0;
height: 1.875em;
background-size: contain;
right: 1.815em;
top: -0.3em;
padding: 0;
}
.cancer_table_btn:focus{
color: #5d7ca2 !important;
background-color: #9dc3e6 !important;
border-color: #8c8c8c !important;
}
.cancer_table_btn:hover{
color: #5d7ca2 !important;
background-color: #9dc3e6 !important;
border-color: #8c8c8c !important;
}
.cancer_table_btn.active{
color: #5d7ca2 !important;
background-color: #9dc3e6 !important;
border-color: #8c8c8c !important;
}
.cancertable_empty{
border: 0.25em solid pink !important;
border-radius: 0.5em !important;
padding: 0.125em !important;
}
.result_title{
background-color: rgb(210, 105, 0) !important;
color: white !important;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
font-size: 1.25em;
float: left;
}
.result_tab{
background: #023d79 !important;
background: linear-gradient(135deg, transparent 0.3em, #023d79 0) !important;
border: none;
float:right;
padding: 0.5em 0.125em 0.5em 0.5em;
margin-top: 0.5em;
cursor: pointer;
}
#cancer_table a:hover{
text-decoration: none;
color: #5d7ca2;
}
#result_contents{
padding-top: 1em;
}
#choice_fields{
padding: 2em 0 0 calc(20% - 1.625em);
}
.result_tab:hover{
background: #d16801;
background: linear-gradient(135deg, transparent 0.3em, #d16801 0);
padding: 0.8em 0.125em 0.5em 1em;
margin-left: -0.5em;
}
.result_tab.active{
background: #d16801 !important;
background: linear-gradient(135deg, transparent 0.3em, #d16801 0) !important;
padding: 0.8em 0.125em 0.5em 1em;
margin-left: -0.5em;
}
.result_tab > a{
writing-mode: vertical-lr !important;
-webkit-writing-mode: vertical-lr !important;
color: white !important;
}
.result_tab_group{
display: none;
}
.result_content_group{
width: 100%;
margin: 0;
float: none;
}
.result_content{
display: block;
min-height: 25em;
border: 0.125em solid #c0cbdd !important;
padding: 0.5em;
}
.result_content:first-of-type{
display: block;
}
.result_content a{
color: #5d7ca2;
}
.result_content span{
color: #5d7ca2;
}
.result_content p{
color: #5d7ca2;
clear: both;
}
.cancer_years{
float:left;
color: #5d7ca2;
background-color: #fff;
border-color: #5d7ca2;
border-width: 0.125em;
margin: 0em;
}
.cancer_years:first-of-type{
margin-left: 1em;
}
.cancer_years:last-of-type{
margin-right: 1em;
}
.cancer_form_field{
margin-left: 1em;
}
#result_table_content a{
float:left;
display: contents;
}
.hint-texts{
color: rgb(104, 104, 104);
font-size: 0.75em;
clear: both;
padding: 0.5em 0;
}
#result_text_content a{
float:left;
}
#result_table_content table{
clear: both;
width:100%;
table-layout: fixed;
overflow-wrap: break-word;
}
#result_table_content table tbody tr{
display: none;
}
#result_table_content table tbody tr:first-of-type{
display: table-row;
}
.white_text,.white_text:link,.white_text:visited{
color:white;
}
.cancer_th{
color: white !important;
background-color: #003d79 !important;
border-right: 0.375em solid white;
border-top: 0.375em solid white;
}
.cancer_td {
background-color: #e9eaf5 !important;
border-right: 0.375em solid white;
border-top: 0.375em solid white;
}
#colon_cancer_predict1_result_block{
display:none;
font-size: 0.825em;
margin-top: 3em;
border-top: #666 solid;
padding-top: 2em;
}
p.texts_show{
display: list-item;
margin-left: 1.5em;
clear: both;
}
div.texts_show{
display: block;
margin-left: 0;
}
.addition{
display: none;
}
#cancer_table_right_result .cancer_table_btn{
padding: 0.25em 1em;
}
#cancer_table_left_result .cancer_table_btn{
padding: 0.25em 1em;
}
.modal-dialog {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%) !important;
overflow: auto;
overflow-y: auto;
}
#colon_cancer_predict1_result{
width: 80%;
}
#cancer_table_right{
float:right;
width:50%;
}
#cancer_table_left{
float:left;
width:50%;
}
#cancer_table_right_result{
width: 50%;
float: right;
}
#cancer_table_left_result{
width: 50%;
float: left;
}
#colon_cancer_predict1_result{
width: 50%;
float: left;
}
.result_title{
margin-top: 1em;
}
* {
-webkit-print-color-adjust: exact !important;
}
.layout-content{
background: #fff !important;
}
}

0
app/controllers/.keep Normal file
View File

View File

@ -0,0 +1,718 @@
# encoding: utf-8
class Admin::Coloncancerpredict1sController < OrbitAdminController
require 'spreadsheet'
require 'rubyXL'
require 'fileutils'
require "axlsx"
require "csv"
#include Admin::Coloncancerpredict1sHelper
before_action ->(module_app = @app_title) { set_variables module_app }
before_action :create_first_field
helper Admin::Coloncancerpredict1sHelper
#before_action :load_access_levels
def initialize
super
@app_title = "coloncancerpredict1"
end
def index
@tags = @module_app.tags
@categories = @module_app.categories.enabled
@filter_fields = filter_fields(@categories, @tags)
@table_fields = [:status, :category, :title, :start_date, :end_date, :last_modified]
@head_images_id = @form_to_show.head_images_id
@title_images_id = @form_to_show.title_images_id
@head_images = []
@title_images = []
@head_images_id.each{|image_id| @head_images.push Colonheadimages1s.find_by(:id=>image_id.to_s)} rescue nil
@title_images_id.each{|image_id| @title_images.push Colonheadimages1s.find_by(:id=>image_id.to_s)} rescue nil
@head_new_image = Colonheadimages1s.new(:coloncancerpredictfields1s_id => @form_to_show.id)
end
def edit
other_in_use_locales = Site.first.in_use_locales.map{|l| l.to_s}
other_in_use_locales.delete(params[:locale])
if !(params["coloncancerpredictfields1s"].nil?)
if !(params["coloncancerpredictfields1s"]["form_show"].nil?)
params["coloncancerpredictfields1s"]["form_show"].each do |num,property|
property.each do |key,value|
if key.include?("_file") && (!value[:temp_file].blank? rescue false)
if value[:id].nil?
mapping_file = ColoncancerPredictMappingFile1.create(value)
else
mapping_file = ColoncancerPredictMappingFile1.find(value[:id])
mapping_file.temp_file = value[:temp_file]
mapping_file.save
end
@form_to_show.form_show[num.to_s][key.to_s] = mapping_file.id
elsif key.include?("_file")
if value[:_destroy] == "1"
mapping_file = ColoncancerPredictMappingFile1.find(value[:id])
mapping_file.destroy
@form_to_show.form_show[num.to_s][key.to_s] = ""
end
end
next if key.include?("_file")
if (key != "old_num")
if key != params[:locale]
@form_to_show.form_show[num.to_s] = {} if @form_to_show.form_show[num.to_s].nil?
type = Coloncancerpredictfields1s::FIELDINFO[key.to_s]
if type && Coloncancerpredictfields1s::Field_relations[type]
type = Coloncancerpredictfields1s::Field_relations[type]
end
type = type.constantize rescue String
if type != Array
if type == Fixnum
@form_to_show.form_show[num.to_s][key.to_s] = value.to_i rescue 0
elsif type == Float
@form_to_show.form_show[num.to_s][key.to_s] = value.to_f rescue 0.0
else
@form_to_show.form_show[num.to_s][key.to_s] = value
end
else
if value.length > 2
@form_to_show.form_show[num.to_s][key.to_s] = YAML.load(value)
else
@form_to_show.form_show[num.to_s][key.to_s] = []
end
end
else
value.each do |sub_property,sub_value|
type = Coloncancerpredictfields1s::FIELDINFO[sub_property.to_s]
if type && Coloncancerpredictfields1s::Field_relations[type]
type = Coloncancerpredictfields1s::Field_relations[type]
end
type = type.constantize rescue String
@form_to_show.form_show[ num.to_s ][ sub_property ] = {} if @form_to_show.form_show[num.to_s][ sub_property ].nil?
if type != Array
if type == Fixnum
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.to_i rescue 0
elsif type == Float
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.to_f rescue 0.0
else
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value
end
else
if sub_value.length > 2
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = YAML.load(sub_value)
else
@form_to_show.form_show[ num.to_s ][ sub_property ][params[:locale].to_s] = []
end
end
if(property["old_num"].present? && property["old_num"] != num.to_s)
other_in_use_locales.each do |locale|
@form_to_show.form_show[ num.to_s ][ sub_property ][locale] = @form_to_show.form_show_was[ property["old_num"] ][ sub_property ][locale]
end
end
end
end
end
end
end
org_nums = @form_to_show.form_show_was.keys
remain_org_nums = params["coloncancerpredictfields1s"]["form_show"].values.map{|property| property["old_num"]}.select{|n| n.present?}
delete_nums = org_nums - remain_org_nums
if !delete_nums.blank?
delete_nums.each do |delete_num|
@form_to_show.form_show.delete(delete_num)
end
end
@form_to_show.form_show = @form_to_show.form_show.values.map.with_index{|v,i| [i.to_s, v]}.to_h
else
@form_to_show.form_show = {}
end
if !params["coloncancerpredictfields1s"]["form_show_in_result"].nil?
params["coloncancerpredictfields1s"]["form_show_in_result"].each do |num,property|
property.each do |key,value|
if key.include?("_file") && (!value[:temp_file].blank? rescue false)
if value[:id].nil?
mapping_file = ColoncancerPredictMappingFile1.create(value)
else
mapping_file = ColoncancerPredictMappingFile1.find(value[:id])
mapping_file.temp_file = value[:temp_file]
mapping_file.save
end
@form_to_show.form_show[num.to_s][key.to_s] = mapping_file.id
elsif key.include?("_file")
if value[:_destroy] == "1"
mapping_file = ColoncancerPredictMappingFile1.find(value[:id])
mapping_file.destroy
@form_to_show.form_show_in_result[num.to_s][key.to_s] = ""
end
end
next if key.include?("_file")
if (key != "old_num")
if key != params[:locale]
@form_to_show.form_show_in_result[num.to_s] = {} if @form_to_show.form_show_in_result[num.to_s].nil?
type = Coloncancerpredictfields1s::FIELDINFO[key.to_s]
if type && Coloncancerpredictfields1s::Field_relations[type]
type = Coloncancerpredictfields1s::Field_relations[type]
end
type = type.constantize rescue String
if type != Array
if type == Fixnum
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value.to_i rescue 0
elsif type == Float
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value.to_f rescue 0.0
else
@form_to_show.form_show_in_result[num.to_s][key.to_s] = value
end
else
if value.length > 2
@form_to_show.form_show_in_result[num.to_s][key.to_s] = YAML.load(value)
else
@form_to_show.form_show_in_result[num.to_s][key.to_s] = []
end
end
else
value.each do |sub_property,sub_value|
type = Coloncancerpredictfields1s::FIELDINFO[sub_property.to_s]
if type && Coloncancerpredictfields1s::Field_relations[type]
type = Coloncancerpredictfields1s::Field_relations[type]
end
type = type.constantize rescue String
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ] = {} if @form_to_show.form_show_in_result[num.to_s][ sub_property ].nil?
if type != Array
if type == Fixnum
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.to_i rescue 0
elsif type == Float
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value.to_f rescue 0.0
else
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = sub_value
end
else
if sub_value.length > 2
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = YAML.load(sub_value)
else
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][params[:locale].to_s] = []
end
end
if(property["old_num"].present? && property["old_num"] != num.to_s)
other_in_use_locales.each do |locale|
@form_to_show.form_show_in_result[ num.to_s ][ sub_property ][locale] = @form_to_show.form_show_was[ property["old_num"] ][ sub_property ][locale]
end
end
end
end
end
end
end
org_nums = @form_to_show.form_show_in_result_was.keys
remain_org_nums = params["coloncancerpredictfields1s"]["form_show_in_result"].values.map{|property| property["old_num"]}.select{|n| n.present?}
delete_nums = org_nums - remain_org_nums
if !delete_nums.blank?
delete_nums.each do |delete_num|
@form_to_show.form_show_in_result.delete(delete_num)
end
end
@form_to_show.form_show_in_result = @form_to_show.form_show_in_result.values.map.with_index{|v,i| [i.to_s, v]}.to_h
else
@form_to_show.form_show_in_result = {}
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','texts_between_Result_and_result_block','prediction_formula','hidden_variables','advance_mode','years_settings']
params_cancer = params.require("coloncancerpredictfields1s").permit!
@create_items.each do |item|
if (@form_to_show[item].class == BSON::Document) || (@form_to_show.send(item).class == Hash)
item_hash = @form_to_show[item]
item_hash = item_hash.merge(params_cancer[item])
@form_to_show[item] = item_hash
elsif @form_to_show[item].class == Array
if params_cancer[item].class != Array
@form_to_show[item] = YAML.load(params_cancer[item]) rescue []
else
@form_to_show[item] = params_cancer[item]
end
@form_to_show[item] = [] if @form_to_show[item].class != Array
else
@form_to_show[item] = params_cancer[item]
end
end
@size = ['small','medium','large']
@size.each{|size| @form_to_show[size] = params["coloncancerpredictfields1s"][size]}
@file_path = Rails.root.to_s + '/app/assets/images/predict_tool'
if !Dir.exist? @file_path
FileUtils.mkdir_p @file_path
end
@images = params["coloncancerpredictfields1s"]['head_images']
@head_images_id = @form_to_show.head_images_id
@delete_index = []
if !@images.nil?
@images.each do |num,image|
if num.to_i < @head_images_id.length && @head_images_id.length != 0
if image['remove_image'] == "1"
@delete_index.push num.to_i
else
@image_id = @head_images_id[num.to_i]
@image = Colonheadimages1s.find_by(:id=>@image_id.to_s)
if !image['sort_number'].nil?
@image.sort_number = image['sort_number'].to_i
@image.save
end
next if image['temp_file'] == nil
@file_name = image['temp_file'].original_filename.gsub('(','_').gsub(')','_').gsub(' ','_') rescue next
@image.sort_number = image['sort_number'].to_i
@image.temp_file = image['temp_file']
@image.save
end
else
@file_name = image['temp_file'].original_filename.gsub('(','_').gsub(')','_').gsub(' ','_') rescue next
@colonheadimages1s = Colonheadimages1s.new(:coloncancerpredictfields1s_id => @form_to_show.id,:title => @app_title+'head_images')
@colonheadimages1s.temp_file = image['temp_file']
@colonheadimages1s.sort_number = image['sort_number'].to_i if !image['sort_number'].nil?
@colonheadimages1s.save
@form_to_show.head_images_id.push @colonheadimages1s.id
end
end
end
@delete_index.reverse!
@delete_index.each do |i|
@image_id = @head_images_id[i.to_i]
Colonheadimages1s.find_by(:id => @image_id ).destroy rescue next
@form_to_show.head_images_id.delete(@image_id)
end
@images = params["coloncancerpredictfields1s"]['title_images']
@title_images_id = @form_to_show.title_images_id
@delete_index = []
if !@images.nil?
@images.each do |num,image|
if num.to_i < @title_images_id.length && @title_images_id.length != 0
if image['remove_image'] == "1"
@delete_index.push num.to_i
else
@image_id = @title_images_id[num.to_i]
@image = Colonheadimages1s.find_by(:id=>@image_id.to_s)
if !image['sort_number'].nil?
@image.sort_number = image['sort_number'].to_i
@image.save
end
next if image['temp_file'] == nil
@file_name = image['temp_file'].original_filename.gsub('(','_').gsub(')','_').gsub(' ','_') rescue next
@image.sort_number = image['sort_number'].to_i
@image.temp_file = image['temp_file']
@image.save
end
else
@file_name = image['temp_file'].original_filename.gsub('(','_').gsub(')','_').gsub(' ','_') rescue next
@colonheadimages1s = Colonheadimages1s.new(:coloncancerpredictfields1s_id => @form_to_show.id,:title => @app_title+'title_images' )
@colonheadimages1s.temp_file = image['temp_file']
@colonheadimages1s.sort_number = image['sort_number'].to_i if !image['sort_number'].nil?
@colonheadimages1s.save
@form_to_show.title_images_id.push @colonheadimages1s.id
end
end
end
@delete_index.reverse!
@delete_index.each do |i|
@image_id = @title_images_id[i.to_i]
Colonheadimages1s.find_by(:id => @image_id ).destroy rescue next
@form_to_show.title_images_id.delete(@image_id)
end
file_ids = (@form_to_show.form_show.values + @form_to_show.form_show_in_result.values).map{|property| [property[:variable],property[:coloncancer_predict_mapping_file1]]}.select{|k,f| f.present?}.to_h
mapping_data_from_csv = {}
if !file_ids.blank?
file_ids.each do |k,v|
mapping_data_from_csv[k] = read_mapping_file(v)
end
end
@form_to_show.mapping_data_from_csv = mapping_data_from_csv.to_json
@form_to_show.save
fork do
@form_to_show.auto_write_predict_js
end
end
@index = 0
Dir.chdir("public") do
while File.exist?('colon_cancerfield_back'+@index.to_s+'1.txt')
@index += 1
end
end
Dir.chdir("public") do
@site_locales = Site.last.in_use_locales.each do |locale|
I18n.with_locale(locale) do
@file_tmp = File.new('colon_cancer_tool_table_tmp_'+locale.to_s+'1.txt', 'w')
tmp_table_texts = create_table(locale)
@file_tmp.write(tmp_table_texts)
@file_tmp.close
end
end
end
Dir.chdir("public") do
@file_back = File.open('colon_cancerfield_back'+@index.to_s+'1.txt', 'w')
@file_back.write(@form_to_show.attributes)
@file_back.close
@file_org = File.open('colon_cancerfield_org'+@index.to_s+'1.txt', 'w')
@file_org.write(Coloncancerpredictfields1s.where("title"=>@app_title+'_back').first.attributes)
@file_org.close
end
redirect_to admin_coloncancerpredict1s_path
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('coloncancerpredict1.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(\'colon_cancer_predict1_result_block\').style[\'font-size\']=\''+size_value+'\';">'+t('coloncancerpredict1.'+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
@disp_value
if @value.class == BSON::Document || @value.class == Hash
@disp_value = @value[current_locale] rescue ""
else
@disp_value = @value
end
@disp_value = "" if @disp_value.nil?
@field_property[key] = @disp_value
end
if @field_property['right'] == 0
next if @field_property["name"].blank?
@table_str_left += '<div data-key='+num.to_s+'>'
@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"].present?
@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].blank?
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"].present?
@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+'"/><input class="num_only_value" type="hidden" /></div>'
else
if @field_property["range"] == []
@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
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"].present?
@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].blank?
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"].present?
@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+'"/><input class="num_only_value" type="hidden" /></div>'
else
if @field_property["range"] == []
@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_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
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="colon_cancer_predict1_result" style="'+((@form_to_show.form_result_is_right == 0) ? 'float:right;' : '')+'"><span class="result_title">'+t("coloncancerpredict1.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("coloncancerpredict1.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('coloncancerpredict1.table.Submit').to_s+'</button>'
@reset_btn_str='<button id="cancer_table_reset">'+t('coloncancerpredict1.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('coloncancerpredict1.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
@disp_value = "" if @disp_value.nil?
@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"].present?
@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].blank?
@field_property["comment_text"] = property["comment_text"][locale.to_s]
break
end
if @field_property["comment_text"].present?
@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+'"/><input class="num_only_value" type="hidden" /></button>'
else
if @field_property["range"] == []
@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_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
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="colon_cancer_predict1_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
@page_num = params[:page] || 1
@results = Coloncancerpredictrecord1.where("title"=>@app_title).desc(:id).page(@page_num).per(10)
@variables = []
@names = []
@form_to_show.form_show.each do |num,property|
property.each do |key,value|
if key == "variable"
@variables.push value
elsif key == "name"
@names.push value[I18n.locale.to_s]
end
end
end
@result_variables = []
@result_names = []
@indexs=[]
@choicenames=[]
if @results.length != 0
@results[0].result.each{|key,value| @result_variables.push key} rescue nil
@result_variables.each do |variable|
@index = @variables.index(variable.to_s)
@result_names.push @names[@index] if !@index.nil?
@indexs.push @index if !@index.nil?
end
@indexs.each do |index|
if @form_to_show.form_show[index.to_s]["is_num"] == 1 || @form_to_show.form_show[index.to_s]["is_float"] == 1
@choicenames.push ""
else
@choicenames.push @form_to_show.form_show[index.to_s]["choice_fields"][I18n.locale.to_s]
end
end
end
@pagination = create_pagination(@page_num.to_i)
end
def export_cancer_tool_record
@cancer_records = Coloncancerpredictrecord1.where("title"=>@app_title).desc(:id)
dir_path = 'tmp/cancer_tool/'
#FileUtils.rm_r(dir_path, :force => true) if Dir.exist?(dir_path)
FileUtils.mkdir dir_path if !Dir.exist?(dir_path) #create dir for storing tmp_file if dir doesn't exist
@filename = ("#{Time.now.year}_%02s_%02s_export_cancer_tool_record.xlsx"%[Time.now.month,Time.now.day]).gsub(" ","0")
Dir.chdir(dir_path) do
File.open(@filename, 'w') do |f|
f.write render_to_string( :handlers=> [:axlsx], :formats=> [:xlsx] ,:partial=> 'export_cancer_tool_record.xlsx',:locals=> {:@results=>@cancer_records} )
end
end
tmp_filename_data = File.read(dir_path +@filename)
send_data(tmp_filename_data, type: 'application/xlsx', disposition: 'attachment', filename: @filename)
end
def create_first_field
if Coloncancerpredictfields1s.where("title"=>(@app_title + "_back")).take_while{true}.count == 0
@form_to_show = Coloncancerpredictfields1s.new()
@form_to_show.title = @app_title +"_back"
@form_to_show.save
end
@form_to_show
if Coloncancerpredictfields1s.where("title"=>@app_title).take_while{true}.count == 0
@form_to_show = Coloncancerpredictfields1s.new()
@form_to_show.title=@app_title
@form_to_show.save
@form_to_show = Coloncancerpredictfields1s.where("title"=>@app_title).first
Dir.chdir("public") do
@site_locales = Site.last.in_use_locales.each do |locale|
I18n.with_locale(locale) do
@file_tmp = File.new('colon_cancer_tool_table_tmp_'+locale.to_s+'1.txt', 'w')
tmp_table_texts = create_table(locale)
@file_tmp.write(tmp_table_texts)
@file_tmp.close
end
end
end
else
@form_to_show = Coloncancerpredictfields1s.where("title"=>@app_title).first
end
end
def create_pagination(page=1,fields=Coloncancerpredictrecord1.all,extra_params="")
page = 1 if page == 0
per_page_num = 10.0
all_page_num = (fields.count / per_page_num).ceil
all_page_num = 1 if all_page_num == 0
pagination = '<div class="PageDetails">'+((I18n.locale.to_s == 'zh_tw') ? "#{page}" : "page #{page}") +'/'+ ((I18n.locale.to_s == 'zh_tw') ? "#{all_page_num}" : "Total #{all_page_num} page(s)")+'<ol class="PageList">'+
((page == 1) ? '<li>['+I18n.t('coloncancerpredict1.prev_page')+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+(page-1).to_s+'"> ['+I18n.t('coloncancerpredict1.prev_page')+'] </a></li>')
if all_page_num > 7
if page <= (all_page_num / 2)
if page <= 7
(1..page).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
else
(1..3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(page-3..page).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
end
(page+1..page+3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(all_page_num-2..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
else
(1..3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(page-3..page).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
if all_page_num - page <= 7
(page+1..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
else
(page+1..page+3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(all_page_num-2..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
end
end
else
(1..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
end
pagination += (((page==all_page_num) ? '<li>['+I18n.t('coloncancerpredict1.next_page')+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+(page+1).to_s+'"> ['+I18n.t('coloncancerpredict1.next_page')+'] </a></li>')+'</ol></div>')
end
def read_mapping_file(mapping_file_id)
mapping_file = ColoncancerPredictMappingFile1.find(mapping_file_id) rescue nil
if !mapping_file.nil?
csv_rows = CSV.read(mapping_file.temp_file.file.path)
titles = csv_rows[0]
infos = {}
titles.each_with_index do |title,i|
infos[title] = []
csv_rows[1..-1].each do |row|
infos[title] << row[i].to_f
end
end
return infos
else
return {}
end
end
end

View File

@ -0,0 +1,201 @@
# encoding: utf-8
require 'rubyXL'
require "json"
class Coloncancerpredict1sController < ApplicationController
def initialize
super
@app_title = "coloncancerpredict1"
end
def calculate
create_first_field
if params['header'].to_i == 1
locale = params['locale'].to_s rescue 'zh_tw'
locale = 'zh_tw' if locale == 'zh_cn'
result = {}
@head_images = {}
@form_to_show.head_images_id.each do |image_id|
next if image_id.to_s == ""
@image = Colonheadimages1s.find_by(:id=>image_id.to_s)
@url = @image.temp_file.to_s
@head_images[@image.sort_number.to_i] = ('<img class="head_logo" alt ="' + Pathname.new(@image.temp_file.file.file).basename.to_s+'" src="'+@url+'"/>')
end
result['head_images'] = Hash[@head_images.sort].values.join('')
@head_images = {}
@form_to_show.title_images_id.each do |image_id|
next if image_id.to_s == ""
@image = Colonheadimages1s.find_by(:id=>image_id.to_s)
@url = @image.temp_file.to_s
@head_images[@image.sort_number.to_i] = ('<img class="head_logo" alt ="' + Pathname.new(@image.temp_file.file.file).basename.to_s+'" src="'+@url+'"/>')
end
result['danger_texts'] = (@form_to_show.danger_texts[locale] rescue '')
result['title'] = Hash[@head_images.sort].values.join('')
result['page_title'] = @form_to_show.title_texts[params[:locale]]
elsif params['get_mapping_data_from_csv'].to_i == 1
result = {}
result['mapping_data_from_csv'] = JSON.parse(@form_to_show.mapping_data_from_csv) rescue {}
else
@record = Coloncancerpredictrecord1.new
@record.title = @app_title
@choice_keys = []
@choice_values = []
@choice_names = []
@form_to_show.form_show.values.each{|choice| @choice_keys.push choice[:variable]}
@form_to_show.form_show.values.each{|choice| @choice_values.push ((choice[:is_num] == 1) ? [] : choice[:choice_fields])}
@form_to_show.form_show.values.each{|choice| @choice_names.push choice[:name]}
@choice_keys.each_with_index{|key,i| @record.names[key] = @choice_names[i]}
@choice_keys.each_with_index{|key,i| @record.values[key] = @choice_values[i]}
params['data'].each do |rec_key,rec_value|
@record.result[rec_key] = rec_value
end
@record.submit_time = Time.now.to_s
@record.save
locale = params['data']['locale'].to_s rescue 'zh_tw'
locale = 'zh_tw' if locale == 'zh_cn'
result = {}
mapping_data_from_csv = JSON.parse(@form_to_show.mapping_data_from_csv) rescue {}
@form_to_show.all_variables.each do |v|
result[v] = 0
end
@form_to_show.form_show.each do |num,property|
@variable = property[:variable]
if @variable.present?
if property[:is_num] == 1
if property[:is_float] == 1
result[@variable] = params['data'][@variable].to_f rescue 0.0
else
result[@variable] = params['data'][@variable].to_i rescue 0
end
elsif property[:choice_fields].present?
if !(@form_to_show.advance_mode)
result[@variable] = params['data'][@variable].to_i rescue 0
else
if property[:need_map_values] == 1
result[@variable] = property[:map_values][params['data'][@variable].to_i - 1]
else
if property[:revert_value] != 1
result[@variable] = params['data'][@variable].to_i - 1
else
result[@variable] = ((property[:choice_fields].length - params['data'][@variable].to_i) rescue params['data'][@variable].to_i)
end
end
end
end
if @form_to_show.advance_mode && property[:coloncancer_predict_mapping_file1].present?
if (mapping_data_from_csv != {})
mapping_hash = mapping_data_from_csv[@variable]
temp_index = 0
temp_value = result[@variable]
mapping_hash.each_with_index do |(k,v),i|
if i == 0
index_val = v.index(temp_value) rescue nil
if !index_val.nil?
temp_index = index_val
else
closest_value = v.min_by{|x| (temp_value-x).abs}
temp_index = v.index(closest_value)
end
end
result[k] = v[temp_index]
end
end
end
end
end
formula_variables = @form_to_show.tmp_lpv_variables
begin
eval_hidden_variables(result)
rescue => e
@form_to_show.generate_eval_formula
eval_hidden_variables(result)
end
begin
eval_formula(result)
rescue => e
@form_to_show.generate_eval_formula
eval_formula(result)
end
result['lpv'] = result[formula_variables.last]
result['lpv_variable'] = {}
formula_variables.each do |variable_name|
result['lpv_variable']["#{variable_name}"] = result[variable_name]
end
@years = @form_to_show.years
result['years'] = @years
@therapy_choices = [I18n.t('coloncancerpredict1.table.Surgeryonly')]
@form_to_show.form_show_in_result.values.each{|choice| @therapy_choices.push choice["name"][locale]}
@therapy_names = @form_to_show.treatment_method
result['treatment_method'] = @therapy_names
result['treatment_method_active_indices'] = @form_to_show.treatment_method_active_indices
result['table'] = @form_to_show.result_table_translations[locale]
year = params['data']['year'] rescue nil
if year.nil?
year = @years.last.to_f
else
year = year.to_f
end
year_index = @years.index(year)
@servive_ratio = eval(@form_to_show.tmp_years_settings_for_ruby[year_index])
@servive_ratio = (@servive_ratio * 100).round(2)
result['texts'] = @form_to_show.result_text_translations[locale]
result['extra_therapy_texts'] = @form_to_show.extra_therapy_texts[locale] rescue @form_to_show.extra_therapy_texts['zh_tw']
result['servive_ratio'] = @servive_ratio
end
result = result.merge(params)
render :json=> result
end
def index
uid = OrbitHelper.params[:uid] rescue ""
tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || []
@table_str = File.read('public/colon_cancer_tool_table_tmp_'+I18n.locale.to_s+'1.txt')
{
"coloncancerpredict1" => [],
"extras"=>{"table"=> @table_str}
}
end
def widget
uid = OrbitHelper.params[:uid] rescue ""
tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || []
@table_str = File.read('public/colon_cancer_tool_table_tmp_'+I18n.locale.to_s+'1.txt')
{
"coloncancerpredict1" => [],
"extras"=>{"table"=> @table_str}
}
end
def create_first_field
if Coloncancerpredictfields1s.where("title"=>(@app_title + "_back")).count == 0
@form_to_show = Coloncancerpredictfields1s.new()
@form_to_show.title = @app_title +"_back"
@form_to_show.save
end
@form_to_show
if Coloncancerpredictfields1s.where("title"=>@app_title).count == 0
@form_to_show = Coloncancerpredictfields1s.new()
@form_to_show.title=@app_title
@form_to_show.save
@form_to_show = Coloncancerpredictfields1s.where("title"=>@app_title).first
else
@form_to_show = Coloncancerpredictfields1s.where("title"=>@app_title).first
end
end
def read_mapping_file(mapping_file)
if mapping_file.class != ColoncancerPredictMappingFile1
mapping_file = ColoncancerPredictMappingFile1.find(mapping_file_id) rescue nil
end
if !mapping_file.nil?
csv_rows = CSV.read(mapping_file.temp_file.file.path)
titles = csv_rows[0]
infos = {}
titles.each_with_index do |title,i|
infos[title] = []
csv_rows[1..-1].each do |row|
infos[title] << row[i].to_f
end
end
return infos
else
return {}
end
end
end

0
app/helpers/.keep Normal file
View File

View File

@ -0,0 +1,37 @@
module Admin::Coloncancerpredict1sHelper
def create_pagination(page=1,fields=Coloncancerpredictrecord1.all,extra_params="")
page = 1 if page == 0
per_page_num = 10.0
all_page_num = (fields.count / per_page_num).ceil
pagination = '<div class="PageDetails">'+((I18n.locale.to_s == 'zh_tw') ? "#{page}" : "page #{page}") +'/'+ ((I18n.locale.to_s == 'zh_tw') ? "#{all_page_num}" : "Total #{all_page_num} page(s)")+'<ol class="PageList">'+
((page == 1) ? '<li>['+I18n.t('coloncancerpredict1.prev_page')+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+(page-1).to_s+'"> ['+I18n.t('coloncancerpredict1.prev_page')+'] </a></li>')
if all_page_num > 7
if page <= (all_page_num / 2)
if page <= 7
(1..page).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
else
(1..3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(page-3..page).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
end
(page+1..page+3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(all_page_num-2..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
else
(1..3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(page-3..page).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
if all_page_num - page <= 7
(page+1..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
else
(page+1..page+3).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
pagination +='<li>...</li>'
(all_page_num-2..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
end
end
else
(1..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '<li>['+page_num.to_s+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+page_num.to_s+'"> '+page_num.to_s+' </a></li>')}
end
pagination += (((page==all_page_num) ? '<li>['+I18n.t('coloncancerpredict1.next_page')+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+(page+1).to_s+'"> ['+I18n.t('coloncancerpredict1.next_page')+'] </a></li>')+'</ol></div>')
end
end

0
app/models/.keep Normal file
View File

View File

@ -0,0 +1,33 @@
# encoding: utf-8
require 'carrierwave/processing/mime_types'
class ColonHeadImagesUploader1 < CarrierWave::Uploader::Base
include CarrierWave::MimeTypes
process :set_content_type
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
# storage :file
# storage :s3
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
return "uploads/#{model.class.to_s.underscore}/predict_tool"
end
# override
def filename
@original_filename
end
def cache_dir
"#{Rails.root}/tmp/uploads"
end
end

View File

@ -0,0 +1,12 @@
# encoding: utf-8
class ColoncancerPredictMappingFile1
require 'carrierwave/processing/mime_types'
include Mongoid::Document
include Mongoid::Timestamps
include CarrierWave::MimeTypes
mount_uploader :temp_file, ColonHeadImagesUploader1
def file_identifier
filename = self.temp_file.file.original_filename rescue ""
end
end

View File

@ -0,0 +1,423 @@
class Coloncancerpredictfields1s
require "pathname"
require 'json'
include Mongoid::Document
include Mongoid::Timestamps
Field_relations = {"number_field"=>"Fixnum","text_area"=>"String"}
FIELDINFO = {"variable"=>"String","name"=>"String","is_num"=>"Fixnum","hint"=>"String","comment_text"=>"String","choice_fields"=>"Array","range"=>"Array","right"=>"Fixnum","is_float"=>"Fixnum","revert_value"=>"Fixnum","map_values"=>"Array","coloncancer_predict_mapping_file1"=>"String","lpv_impact"=>"Float","active_choice"=>"number_field","disable_condition"=>"text_area"}
NonLoclaized = ["variable","is_num","range","right","is_float","revert_value","map_values","coloncancer_predict_mapping_file1","lpv_impact","active_choice","disable_condition"]
AdvanceFields = ["revert_value","map_values","coloncancer_predict_mapping_file1"]
TherapyFields = ["variable","name","hint","comment_text","choice_fields","lpv_impact","active_choice","disable_condition"]
TherapyOnly = ["lpv_impact","active_choice","disable_condition"]
field :title ,type:String ,default:""
field :advance_mode, type: Boolean, default: false
field :form_show , :type=> Hash ,default: {
"0"=>{"variable"=>"age", "name"=>{"zh_tw"=>"年齡<br/>(Age)", "en"=>"Age"}, "is_num"=>1, "hint"=>{"zh_tw"=>"從 20 歲(含)開始至 80 歲 (含)以下", "en"=>"Age must be between 18 and 93"}, "comment_text"=>{"zh_tw"=>"年齡為該病人於確診罹患大 腸癌時之年齡", "en"=>"Age at diagnosis"}, "choice_fields"=>{"zh_tw"=>[], "en"=>[]}, "range"=>[20, 80], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"1"=>{"variable"=>"size", "name"=>{"zh_tw"=>"腫瘤 大小(單位:mm)<br/>(Tumor size)", "en"=>"Tumor size"}, "is_num"=>1, "hint"=>{"zh_tw"=>"", "en"=>"The unit of tumor size is millimeter (mm)"}, "comment_text"=>{"zh_tw"=>"若有多個原發腫瘤,請輸入最大尺寸之原發腫瘤、上限為 100mm", "en"=>"If there was more than one primary tumor, please enter the size of the largest one."}, "choice_fields"=>{"zh_tw"=>[], "en"=>[]}, "range"=>[1, 100], "right"=>1, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"2"=>{"variable"=>"lymph_nodes_examined", "name"=>{"zh_tw"=>"區域淋巴結檢查數目<br/>(Regional lymph nodes examined)", "en"=>"Regional lymph nodes examined"}, "is_num"=>1, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["未知"], "en"=>["unknown"]}, "range"=>[0, 90], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"3"=>{"variable"=>"lymph_nodes_positive", "name"=>{"zh_tw"=>"區域淋巴結侵犯數目<br/>(Regional lymph nodes positive)", "en"=>"Regional lymph nodes positive"}, "is_num"=>1, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"此變項為預測重要變數,若無此資訊預測容易失真。", "en"=>"Regional lymph nodes positive is a key predictive variable. If this information is omitted, the prediction result would be biased."}, "choice_fields"=>{"zh_tw"=>["未知"], "en"=>["unknown"]}, "range"=>[0, 90], "right"=>1, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"4"=>{"variable"=>"grade", "name"=>{"zh_tw"=>"腫瘤級數<br/>(Tumor grade)", "en"=>"Tumor grade"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"腫瘤級數代表腫瘤組織與正常組織間的分化程度,若無分 化級數資訊,請選 擇“未知”選項,將以級數 1 進行預測。", "en"=>"The grade refers to how different the cancer cells are from normal cells. Please select “unknown” if there is no information about grade. The prediction model would use “grade 2” as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["1", "2", "3", "未知"], "en"=>["1", "2", "3", "unknown"]}, "range"=>[], "right"=>0, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]},
"5"=>{"variable"=>"pstage", "name"=>{"zh_tw"=>"病理分期<br/>(pathologic stage)", "en"=>"Pathologic stage"}, "is_num"=>0, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"若無分期資訊,請選擇“未知”選項,將以病理分期第 1 期進行預測。", "en"=>"ER status describes the status of estrogen receptor. Please select “unknown” if there is no information about ER status. The prediction model would use “Positive” (the majority class) as the alternative variable."}, "choice_fields"=>{"zh_tw"=>["1", "2", "3", "4", "未知"], "en"=>["positive", "negative", "unknown"]}, "range"=>[], "right"=>1, "is_float"=>0, "need_map_values"=>0, "revert_value"=>0, "map_values"=>[]}
}
field :form_show_in_result , :type=> Hash ,default: {
"0"=>{"variable"=>"Chemotherapy", "name"=>{"zh_tw"=>"化學治療", "en"=>"Chemotherapy"}, "hint"=>{"zh_tw"=>"", "en"=>""}, "comment_text"=>{"zh_tw"=>"", "en"=>""}, "choice_fields"=>{"zh_tw"=>["", ""], "en"=>["No", "Yes"]}, "lpv_impact"=>-0.6693, "active_choice"=>2, "disable_condition"=>""}
}
field :form_result_is_right , :type=> Integer ,default: 0
field :text_descibe ,type:Hash ,default: {
"zh_tw"=>"歡迎使用台灣準備大腸癌預後系統!<br />\r\n本預測系統由台灣癌症登記資料庫2007至2015年間共20,218位大腸癌病 人與經<br />\r\n驗證美國流行病學癌症資料庫22,670位病人所建立 。<br />\r\n若要開始 請在下方選擇相關資訊",
"en"=>"Welcome to the Taiwan Breast Cancer Prediction System!<br />\r\nThe 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 />\r\nTo start, please select the information below."
}
field :small ,type:Hash ,default:{'font_size'=>"0.825em",'active'=>0}
field :medium ,type:Hash ,default:{'font_size'=>"1em",'active'=>1}
field :large ,type:Hash ,default:{'font_size'=>"1.25em",'active'=>0}
field :head_images_id ,type:Array , default: []
field :title_images_id ,type:Array , default: []
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 :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 :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 :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 :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 :prediction_formula , type: String ,default: "lpv = ((age - 62.31261) * (0.01385)+ (size - 45.85882)* (0.00786) + (nposit - 0.109264)* (1.83191) +
grade_2*0.29793+grade_3*0.67389+pstage_2*1.1152+
pstage_3*2.2501+pstage_4*3.6206+chemo*(-0.6693)
)"
field :years_settings , type: Array , default: ["exp(-0.005433642)^exp(lpv)", "exp(-0.02357545)^exp(lpv)", "exp(-0.03637668)^exp(lpv)"]
field :tmp_years_settings , type: Array , default: []
field :tmp_years_settings_for_ruby , type: Array , default: []
field :hidden_variables, type: String, default: "ratio = (lymph_nodes_examined == 0 ? 0 : (1.0 * lymph_nodes_positive / lymph_nodes_examined))
ratio = (ratio > 1 ? 1 : ratio)
nposit = ((ratio + 0.1) / 0.1) ^ 0.5
grade_1 = (grade == 1 || grade == 4) ? 1 : 0
grade_2 = (grade == 2) ? 1 : 0
grade_3 = (grade == 3) ? 1 : 0
pstage_2 = (pstage == 2) ? 1 : 0
pstage_3 = (pstage == 3) ? 1 : 0
pstage_4 = (pstage == 4) ? 1 : 0
chemo = (Chemotherapy == 2) ? 1 : 0
"
field :fix_hidden_variables, type: Array, default: []
field :tmp_hidden_variables_for_ruby, type: String, default: ""
field :tmp_hidden_variables_for_js, type: String, default: ""
field :lpv_calc, type: Hash, default: {} #for js code
field :tmp_lpv_ruby_code, type: String, default: ""
field :tmp_lpv_variables, type: Array, default: []
field :mapping_data_from_csv , type: String ,default: ""
field :all_variables, type: Array, default: []
field :treatment_method, type: Array, default: ['Surgery_only']
field :treatment_method_active_indices, type: Array, default: [1]
field :result_table, type: String, default: "", localize: true
field :result_text, type: String, default: "", localize: true
field :therapy_lpv, type: Array, default: [0]
#before_create :set_expire
before_save do
self.form_show.each do |num,property|
property[:need_map_values] = (property[:map_values].class == Array && property[:choice_fields].class == Array && property[:map_values].length == property[:choice_fields].length) ? 1 : 0
end
result_keys = []
self.form_show.each do |num,property|
variable_name = property[:variable]
if variable_name.present?
result_keys << variable_name
end
end
self.form_show_in_result.each do |num,property|
variable_name = property[:variable]
if variable_name.present?
result_keys << variable_name
end
end
mapping_data = JSON.parse(self.mapping_data_from_csv) rescue {}
if self.advance_mode && mapping_data.present?
mapping_data.each do |k,v|
result_keys += (v.keys rescue [])
end
end
result_keys = result_keys.uniq
self.all_variables = result_keys
formula = text_to_math(self.prediction_formula)
tmp_hidden_variables = text_to_math(self.hidden_variables)
result_keys.each do |k|
formula = formula.gsub(/(\A|[^\w])#{k}($|[^\w])/){|f| "#{$1}result[\"#{k.strip}\"]#{$2}" }
tmp_hidden_variables = tmp_hidden_variables.gsub(/(\A|[^\w])#{k}($|[^\w])/){|f| "#{$1}result[\"#{k.strip}\"]#{$2}" }
end
self.tmp_hidden_variables_for_js = tmp_hidden_variables.rstrip.gsub(/\n\s+/,"\n ").gsub("\n",";\n") + ";"
self.fix_hidden_variables = []
self.tmp_hidden_variables_for_ruby = tmp_hidden_variables.split(/^([^=!]+)=([^=!])/).select{|s| s.present?}.each_slice(2).map do |a,b|
a = a.strip
self.fix_hidden_variables << a
if b
("result[\"#{a}\"]=" + b.gsub("\n",""))
else
a
end
end.join("\n")
self.fix_hidden_variables = self.fix_hidden_variables.uniq
formula = formula.split(/^([^=!]+)=([^=!])/).select{|s| s.present?}.each_slice(2).map do |a,b|
a = a.strip
if b
("result[\"#{a}\"]=" + b.gsub("\n",""))
else
a
end
end.join("\n")
self.fix_hidden_variables.each do |v|
formula = formula.gsub(/(\A|[^\w\"])#{v}($|[^\w])/){|f| "#{$1}result[\"#{v.strip}\"]#{$2}"}
self.tmp_hidden_variables_for_ruby = self.tmp_hidden_variables_for_ruby.gsub(/(\A|[^\w\"])#{v}($|[^\w])/){|f| "#{$1}result[\"#{v.strip}\"]#{$2}"}
end
self.tmp_lpv_ruby_code = formula
formula_variables = formula.enum_for(:scan,/([^\=\(\)]+)?=[^=]/).map {|x| x[-1] }.compact.map{|s| s.strip[8..-3]}
self.tmp_lpv_variables = formula_variables
self.tmp_years_settings = self.years_settings.map do |s|
text_to_math(s)
end
self.tmp_years_settings_for_ruby = self.tmp_years_settings.clone
formula_variables.each do |variable_name|
self.tmp_years_settings_for_ruby = self.tmp_years_settings_for_ruby.map do |y|
y.gsub(variable_name,"result[\"#{variable_name}\"]")
end
end
self.treatment_method = ['Surgery_only']
self.form_show_in_result.values.each do |choice|
variable = choice["variable"]
if variable.present?
self.treatment_method << variable
end
end
tmp_table_translations = {}
tmp_text_translations = {}
@years = self.years
@head_name = ['Treatment','Additional_Benefit','Overall_Survival']
# @head_name = ['Treatment','Overall_Survival']
@therapy_names = self.treatment_method
I18n.available_locales.each do |locale|
I18n.with_locale(locale) do
@table_head = @head_name.map{|name| I18n.t('coloncancerpredict1.table.'+name)}
@therapy_choices = [I18n.t('coloncancerpredict1.table.Surgeryonly')]
self.form_show_in_result.values.each{|choice| @therapy_choices.push choice["name"][locale].to_s}
tmp_table = "<span class=\"result_title print_only\">#{I18n.t("coloncancerpredict1.table.table")}</span><div style=\"clear: both\"></div>"
tmp_table += '<input id="current_year" type="hidden" value="'+@years[-1].to_s+'" index="0"/><p id="cancer_table_texts">'+self.table_above_texts[locale].to_s+'</p>'
tmp_table += ('<a style="display: inline-block;">'+(locale.to_s == 'zh_tw' ? '第' : '')+'</a><a style="display: inline-block;">')
@years.each{|year| tmp_table += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm">'+year.to_s+'</button>')}
tmp_table += ('</a><a style="display: inline-block;">'+(locale == 'zh_tw' ? '年' : '')+'</a>')
tmp_table += '<table><thead><tr>'
@table_head.each_with_index{|head,index| tmp_table += ('<th class="cancer_th '+@head_name[index]+'">' + head + '</th>')}
tmp_table += '</tr></thead><tbody>'
@therapy_choices.each_with_index do |choice,i|
tmp_table += '<tr class="'+@therapy_names[i].to_s+'">'
@table_head.each_with_index do |head,index|
tmp_table += ('<td class="cancer_td '+ @head_name[index]+'">' + ((index == 0) ? (((i==0)? '' : '+') + choice) : '-') + '</td>')
end
tmp_table += '</tr>'
end
tmp_table_translations[locale] = tmp_table
@texts = self.text_above_texts[locale].to_s.gsub('<br/>','</span><br/><span>').gsub('{{Surgery_only}}','<span class="'+@therapy_names[0]+' Overall_Survival"></span>')
@texts = @texts.split('{{years}}')
@texts.delete('')
tmp_text = "<span class=\"result_title print_only\">#{I18n.t("coloncancerpredict1.table.text")}</span><div style=\"clear: both\"></div>"
tmp_text += ('<span>'+@texts[0].to_s)
@years.each{|year| tmp_text += ('<button class="cancer_years cancer_table_btn btn btn-default btn-sm" style="float:none;">'+year.to_s+'</button>')}
if @texts.count > 1
tmp_text += (@texts[1]+'</span>') if @texts.count > 1
else
tmp_text += '</span>'
end
if !self.surgery_only_texts[locale].blank?
@surgery_only_texts = self.surgery_only_texts[locale]
@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"></span><span>')
@surgery_only_texts = @surgery_only_texts.gsub('{{surgery_year}}','</span><span class="surgery_year">'+@years[-1].to_s+'</span><span>')
@surgery_only_texts += '</span>'
else
@surgery_only_texts = ''
end
tmp_text += @surgery_only_texts
tmp_text += '<span class="addition">'+(self.extra_texts[locale].to_s rescue '')+'</span><div class="extra-text" style="display:none;"><div class="texts_show" style="clear:both;"></div></div></p>'
tmp_text_translations[locale] = tmp_text
end
end
self.result_table_translations = tmp_table_translations
self.result_text_translations = tmp_text_translations
self.treatment_method_active_indices = [1]
self.form_show_in_result.each do |num, property|
v = property[:active_choice]
if v.present?
self.treatment_method_active_indices << (v - 1)
else
self.treatment_method_active_indices << 1
end
end
self.lpv_calc = get_years_settings_dict
self.generate_eval_formula
end
def generate_eval_formula
eval_hidden_variables = "def eval_hidden_variables(result); #{self.tmp_hidden_variables_for_ruby}; end"
Coloncancerpredict1sController.module_eval(eval_hidden_variables)
eval_formula = "def eval_formula(result); #{self.tmp_lpv_ruby_code}; end"
Coloncancerpredict1sController.module_eval(eval_formula)
end
def generate_jscode
js_code = "var map_values , mapping_hash , temp_index ,temp_value , index , closest_value;\r\n"
mapping_data_from_csv = JSON.parse(self.mapping_data_from_csv) rescue {}
tmp_hash = self.form_show.values + self.form_show_in_result.values
tmp_hash.each do |property|
@variable = property[:variable]
if @variable.present?
if property[:is_num] == 1
js_code += " result['#{@variable}'] = Number(result_json['#{@variable}']);\r\n"
elsif property[:choice_fields].present?
if !(self.advance_mode)
js_code += " result['#{@variable}'] = Number(result_json['#{@variable}']);\r\n"
else
if property[:need_map_values] == 1
js_code += " map_values = #{property[:map_values]};\r\n"
js_code += " result['#{@variable}'] = map_values[Number(result_json['#{@variable}'']) - 1];\r\n"
else
if property[:revert_value] != 1
js_code += " result['#{@variable}'] = Number(result_json['#{@variable}']) - 1;\r\n"
else
js_code += " result['#{@variable}'] = (#{property[:choice_fields].length} - Number(result_json['#{@variable}']));\r\n"
end
end
end
end
if self.advance_mode && property[:coloncancer_predict_mapping_file1].present?
if (mapping_data_from_csv != {} && !mapping_data_from_csv[@variable].blank?)
js_code += " mapping_hash = mapping_data_from_csv['#{@variable}'];\r\n"
js_code += " temp_index = 0;\r\n"
js_code += " temp_value = result['#{@variable}'];\r\n"
js_code += " index = 0;
$.each(mapping_hash,function(k,v){
if( index == 0 ){
var index_val = v.indexOf(temp_value);
if( index_val != -1 ){
temp_index = index_val;
}else{
closest_value = v.get_nearest_value(temp_value);
temp_index = v.indexOf(closest_value)
}
}
result[k] = v[temp_index];
index++;
});\r\n"
end
end
end
end
js_code += "\n Object.keys(result).forEach(function(k){
if(Number.isNaN(result[k])){
result[k] = 0;
}
})"
js_code += "\n #{self.tmp_hidden_variables_for_js}"
formula = text_to_math(self.prediction_formula)
self.all_variables.each do |k|
formula = formula.gsub(/(\A|[^\w])#{k}($|[^\w])/){|f| "#{$1}result[\"#{k.strip}\"]#{$2}" }
end
formula_variables = self.tmp_lpv_variables.map{|v| v}
js_code = "\n function calculate_first_lpv(result_json){
result = {};
#{js_code}
try{
#{formula.gsub(/\s{2,10}/," ").gsub("\n","\n ")}
}catch(e){console.log(e)};
result['lpv_variable'] = {};
#{formula_variables.map{|v| "result['lpv_variable']['#{v}'] = #{v};"}.join("\n ") }
result['lpv'] = #{formula_variables.count == 0 ? 0 : formula_variables.last};
result['lpv_variable']['lpv'] = result['lpv'];
return result;
};
function calculate_and_change_result_value(obj){
obj.servive_ratio_arr = [];
for(var i = 0;i<obj.active_treatment.length;i++){
var servive_ratio = round(calculate_servive_ratio(obj.year,obj.lpv_real[i])*100,2);
var benefit = servive_ratio - obj.servive_ratio_arr[obj.servive_ratio_arr.length-1];
obj.servive_ratio_arr.push(servive_ratio);
$('tr.'+obj.active_treatment[i]+' td.Overall_Survival').html(servive_ratio+'%');
$('.'+obj.active_treatment[i]+'.Overall_Survival').html(Math.round(servive_ratio));
if(i != 0){
$('tr.'+obj.active_treatment[i]+' td.Additional_Benefit').html(round(benefit,2)+'%');
$('.'+obj.active_treatment[i]+'.Additional_Benefit').html(Math.round(benefit));
}
}
//$('.'+obj.active_treatment[0]+'.Overall_Survival').html(Math.round(obj.servive_ratio_arr[0]));
};"
@years = self.years
switch_texts = "
#{formula_variables.map{|v| "var #{v} = obj['#{v}'];"}.join("\n ")}
switch(year) {"
@years.each do |year|
year_index = @years.index(year)
switch_texts +=
"
case '#{year}':
servive_ratio = #{text_to_math(self.years_settings[year_index])};
break;"
end
switch_texts += "
default:
console.log('not found year.');
}"
js_code = js_code +"
function calculate_servive_ratio(year,obj){
var servive_ratio;#{switch_texts}
return servive_ratio;
}
"
return js_code
end
def text_to_math(text)
text.gsub("\r\n","\n").gsub('^','**').gsub('exp','Math.exp').gsub('log','Math.log')
end
def replace_str_with_idx(org_str,st, ed, replace_str)
org_str.slice!(st, ed - st + 1)
org_str.insert(st, replace_str)
org_str
end
def auto_write_predict_js
js_codes = generate_jscode
module_app_path = Pathname.new(File.expand_path(__dir__)).dirname.dirname.to_s
save_path = module_app_path + '/app/assets/javascripts/colon_cancer_predict1.js'
file_texts = File.read(save_path)
need_write = false
str1 = "/* auto add start */"
index1 = file_texts.index(str1)
str2 = "/* auto add end */"
index2 = file_texts.index(str2)
if (!index1.nil? && !index2.nil?)
file_texts = replace_str_with_idx(file_texts, index1 + str1.length, index2 - 1, js_codes)
need_write = true
end
str3 = "/*lpv_calc_formula_start*/"
index3 = file_texts.index(str3)
str4 = "/*lpv_calc_formula_end*/"
index4 = file_texts.index(str4)
if (!index3.nil? && !index4.nil?)
file_texts = replace_str_with_idx(file_texts, index3 + str3.length, index4 - 1, self.lpv_calc.to_json.gsub("@",".") + ';')
need_write = true
end
tmp_disable_jscodes = ""
str5 = "/*disable_condition start*/"
index5 = file_texts.index(str5)
str6 = "/*disable_condition end*/"
index6 = file_texts.index(str6)
self.form_show_in_result.each do |num,property|
if property[:disable_condition].present?
tmp = property[:disable_condition].clone
self.all_variables.each do |k|
tmp = tmp.gsub(/(\A|[^\w])#{k}($|[^\w])/){|f| "#{$1}post_json[\"#{k}\"]#{$2}" }
end
variable = property[:variable]
tmp_disable_jscodes += "\n if(#{tmp}){
$('##{variable} .cancer_table_btn').attr('disabled','disabled');
$('[for=\"#{variable}\"]').css('color','rgb(204, 204, 204)');
}else{
$('##{variable} .cancer_table_btn').removeAttr('disabled');
$('[for=\"#{variable}\"]').css('color','');
}"
end
end
if (!index5.nil? && !index6.nil?)
tmp_disable_jscodes += "\n\t\t\t"
file_texts = replace_str_with_idx(file_texts, index5 + str5.length, index6 - 1, tmp_disable_jscodes)
need_write = true
end
str7 = "/*therapy_lpv start*/"
index7 = file_texts.index(str7)
str8 = "/*therapy_lpv end*/"
index8 = file_texts.index(str8)
self.therapy_lpv = [0]
self.form_show_in_result.each do |num,property|
if property[:lpv_impact].present?
self.therapy_lpv << property[:lpv_impact]
else
self.therapy_lpv << 0
end
end
if (!index7.nil? && !index8.nil?)
file_texts = replace_str_with_idx(file_texts, index7 + str7.length, index8 - 1, self.therapy_lpv.to_s + ';')
need_write = true
end
if need_write
File.write(save_path,file_texts)
end
end
def get_years_settings_dict
lpv_variable_name = (prediction_formula.include?("=") ? prediction_formula.split("=")[0].strip : "" rescue "")
res = self.years.map.with_index do |y, i|
tmp_formula = self.tmp_years_settings[i]
if lpv_variable_name.present?
tmp_formula = tmp_formula.gsub(lpv_variable_name, "lpv_current")
else
tmp_formula = tmp_formula.gsub("lpv", "lpv_current")
end
[y.to_s.sub(".","@"), tmp_formula]
end
res.to_h
end
end

View File

@ -0,0 +1,25 @@
class Coloncancerpredictrecord1
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include OrbitModel::Impression
# encoding: utf-8
include OrbitTag::Taggable
include OrbitCategory::Categorizable
field :title ,type:String ,default:""
field :submit_time ,type:String ,default:""
field :result , type:Hash , default:{}
field :names , type:Hash , default:{}
field :values , type:Hash , default:{}
field :submit_numbers , type:Fixnum , default: 1
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)}
before_save :set_submit_times
def set_submit_times
self.submit_time = Coloncancerpredictrecord1.all.count + 1
end
def check_missing_data
missing_keys = self.names.keys - self.result.keys rescue []
missing_keys.each{|k| self.result[k] = "" }
end
end

View File

@ -0,0 +1,13 @@
class Colonheadimages1s
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include OrbitModel::Impression
# encoding: utf-8
include OrbitTag::Taggable
include OrbitCategory::Categorizable
mount_uploader :temp_file, ColonHeadImagesUploader1
field :coloncancerpredictfields1s_id ,type:String ,default:""
field :title ,type:String ,default:""
field :sort_number ,type:Integer ,default: 0
end

0
app/views/.keep Normal file
View File

View File

@ -0,0 +1,38 @@
# encoding: utf-8
wb = xlsx_package.workbook
wb.add_worksheet(name: "cancer_tool") do |sheet|
if !@results[0].nil?
row = []
title = sheet.styles.add_style(:bg_color => "FFFF00",:border=>{ :style => :thin, :color => "666666" },:alignment=>{ :horizontal => :center,:vertical => :center ,:wrap_text => true})
column = sheet.styles.add_style(:alignment=>{ :horizontal => :center,:vertical => :center ,:wrap_text => true},:border=>{ :style => :thin, :color => "666666" })
row << ((I18n.locale=="en") ? 'submit time' : '提交時間')
@fields = @results.first.names.keys
@fields.each do |field_name|
row << @results.first.names[field_name][I18n.locale.to_s].split('<br/>')[0]
end
#export data start
export_data_rows = []
@results.each do |result|
temp_row = []
temp_row << result.created_at.to_s
result.result.each do |key,value|
if key != "locale"
if (result.values[key][I18n.locale.to_s].length == 0 rescue true)
temp_row << value
else
v = result.values[key][I18n.locale.to_s][value.to_i-1] rescue nil
temp_row << (v.nil? ? value : v)
end
end
end
export_data_rows << temp_row
end
#export data end
sheet.add_row row , :style=> title,:widths => row.map{|cell| (cell.length* 11/ 2).round}
export_data_rows.each do |infos_row|
sheet.add_row infos_row , :style=> column
end
end
end

View File

@ -0,0 +1,37 @@
<tr>
<td class="remove_div">❌</td>
<td class="sort_div"></td>
<% keys.each do |key| %>
<td class="<%=key%>">
<% if key.include? "_file" %>
<%= render :partial => 'form_file', :object => (ColoncancerPredictMappingFile1.where(:id=> property[key]).first rescue nil), :locals => {:f => make_fields, :key=>key} %>
<% else %>
<% value = property[key] %>
<% value_type = Coloncancerpredictfields1s::FIELDINFO[key] %>
<% value = "[]" if property == {} && value_type == 'Array' %>
<% is_localized = Coloncancerpredictfields1s::NonLoclaized.exclude?(key) %>
<% @value= value %>
<% if is_localized %>
<% @disp_value = @value[I18n.locale.to_s] rescue "" %>
<%else%>
<% @disp_value = @value %>
<%end%>
<% field_type = ((value_type == 'String' || value_type == 'Array' || value_type == 'Float') ? "text_field" : value_type) %>
<% if value_type == 'Fixnum' %>
<% if @value == 1%>
<%= make_fields.check_box key,{:checked=>true,:class=>"checkbox",:style=>"float:left;"}%>
<% else%>
<%= make_fields.check_box key,{:checked=>false,:class=>"checkbox",:style=>"float:left;"}%>
<%end%>
<% elsif is_localized %>
<%=make_fields.fields_for I18n.locale.to_s do |locale_fields|%>
<%= locale_fields.send(field_type, key,{:value=>@disp_value}) %>
<%end%>
<% else %>
<%= make_fields.send(field_type, key,{:value=>@disp_value})%>
<%end%>
<%end%>
</td>
<%end%>
<td><%= make_fields.hidden_field :old_num,:value=>num.to_s %></td>
</tr>

View File

@ -0,0 +1,33 @@
<% if form_file.nil? %>
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
<% else %>
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
<% if form_file.temp_file.blank? %>
<%= t(:no_file) %>
<% else %>
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.temp_file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
<% end %>
<% end %>
<%= f.fields_for key do |f|%>
<div class="input-prepend input-append">
<label>
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
<i class="icons-paperclip"></i>
<%= f.file_field :temp_file %>
</span>
<div class="uneditable-input input-medium">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"><%= (form_file.nil? || form_file.temp_file.blank?) ? t(:select_file) : t(:change_file) %></span>
</div>
</label>
</span>
<% if !form_file.nil? %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id,:value=>(form_file.id) %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>
</div>
<% end %>

View File

@ -0,0 +1,26 @@
<div class="input-prepend input-append start-line">
<span class="add-on icons-link" title="<%= t(:url) %>"></span>
<%= f.text_field :url, class: "input-large", placeholder: t(:url) %>
<span class="add-on icons-pencil" title="<%= t(:url_alt) %>"></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-large", placeholder: t(:url_alt), :value => (form_link.title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
<% if form_link.new_record? %>
<span class="delete_link add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>

View File

@ -0,0 +1,30 @@
<div class="control-group">
<div class="controls">
<!-- if this page editing please add class "fileupload-edit" -->
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
<span class="show_span"><%= t('coloncancerpredict1.sort_num')+': ' %></span>
<%= f.text_field 'sort_number',{:class=>'sort_num',:value=>((image_form['sort_number'] == nil) ? i+1 : image_form['sort_number'] ),:style=>'float: left;width: 3em;'} %>
<span class="show_span"><%= t('coloncancerpredict1.logo')+': ' %></span>
<div class="fileupload-new thumbnail pull-left">
<% if image_form.temp_file.file.present? %>
<%= image_tag( image_form.temp_file, :size=>"120x120") rescue ''%>
<% else %>
<%= image_tag "/assets/site-logo.png", :class => "pull-left upload-picture"%>
<% end %>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<% if image_form.temp_file.file.present?%>
<span class="btn btn-file">
<%= f.file_field :temp_file, {:id => "input-upload", :class => 'fileupload-new', :accept=> 'image/png,image/gif,image/jpeg'} %><%= t('preferences.change') %>
</span>
<%= f.check_box :remove_image,{:checked=>false} %>
<%= t(:remove) %> <%= (I18n.locale.to_s == 'en') ? ' this logo' : '該logo' %>
<%else%>
<span class="btn btn-file">
<%= f.file_field :temp_file,{ :id => "input-upload", :class => 'fileupload-new', :accept=> 'image/png,image/gif,image/jpeg'} %><%= t('preferences.select_image') %>
</span>
<%end%>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
</div>
</div>
</div>

View File

@ -0,0 +1,477 @@
<%= stylesheet_link_tag "lib/fileupload"%>
<%= stylesheet_link_tag "lib/togglebox"%>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%#= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%#= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<%= javascript_include_tag "form" %>
<% end %>
<style type="text/css">
.sort_div:before{
content: "\e096";
font-family: 'entypo';
cursor: pointer;
}
.sort_div{
padding: 1em;
}
.sort_table tbody td:last-child{
display: none;
}
.remove_div{
cursor: pointer;
}
.remove_div:hover{
font-size: 1.3em;
}
<% Coloncancerpredictfields1s::AdvanceFields.each do |field| %>
table .<%=field%>{
display: none;
}
table.advance_mode .<%=field%>{
display: table-cell;
}
<% end%>
.solid_line_hr{
margin: 0.3em;
border-top: 0.2em dashed;
}
.sort_table input, .sort_table textarea{
font-family: sans-serif;
}
.advance_mode_help_btn{
float:left;
cursor: pointer;
padding: 0em 0.475em;
font-size: 1.25em;
border-radius: 1.5em;
background-color: rgb(210, 106, 2);
border-color: rgb(210, 106, 2);
color: white;
width: 1.8em;
height: 1.8em;
line-height: 1em;
}
#show_advance_mode_modal {
display: none;
}
</style>
<div id="show_advance_mode_modal" class="modal fade">
<div class='modal-dialog'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' aria-hidden='true' class='close'>×</button>
<h4 class='modal-title'>
<%= t("coloncancerpredict1.module_mode") %>
</h4>
</div>
<div class="modal-body">
<%= t("coloncancerpredict1.advance_mode_hint2").html_safe %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default">Close</button>
</div>
</div>
</div>
</div>
<div style="clear:both;"></div>
<%=form_for @form_to_show ,:url=>{:controller=>"coloncancerpredict1s" ,:action=>"edit"} do |form|%>
<span class="show_span"><%= t('coloncancerpredict1.title') %></span>
<div style="clear:both;"></div>
<label class="label_left" for="title_text"><%= t('coloncancerpredict1.title_text')+':' %></label>
<%=form.fields_for :title_texts do |locale_fields|%>
<%=locale_fields.text_field I18n.locale.to_s ,{:value => @form_to_show.title_texts[I18n.locale.to_s],:id=>"title_text"} %>
<% end %>
<% if @title_images.length != 0%>
<% @title_images.each_with_index do |temp_image,i| %>
<%= form.fields_for "title_images" do |image_fields| %>
<div class="image_field title_images" value="<%=(i+1).to_s%>">
<%= image_fields.fields_for i.to_s do |image_field| %>
<%= render :partial => 'image_form', :object => temp_image, :locals => {:f => image_field, :i => i} %>
<% if i.to_i == @title_images.length - 1%>
<script>
$(document).on('click', '#add_file.title_images', function(){
var old_id = $('.image_field.title_images').eq(-1).attr('value');
if( old_id == undefined)
old_id = 0;
else
old_id = Number(old_id);
var new_id = old_id + 1;
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => i}).gsub("\"","\'").html_safe %>"
$(this).parent().siblings('.add-target.title_images').before(('<div class="image_field title_images" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
var name = $('.image_field.title_images').eq(-1).find('[type="file"]').attr('name');
$('.image_field.title_images').eq(-1).find('[type="file"]').attr('name',name.replace("<%=i%>",new_id-1));
name = $('.image_field.title_images').eq(-1).find('input.sort_num').attr('name');
$('.image_field.title_images').eq(-1).find('input.sort_num').attr('name',name.replace("<%=i%>",new_id-1));
new_id = $('.image_field.title_images').eq(-2).find('input.sort_num').val();
$('.image_field.title_images').eq(-1).find('input.sort_num').val(Number(new_id)+1);
formTip();
});
</script>
<% end %>
<% end %>
<% end %>
<% end %>
<% else %>
<%= form.fields_for "title_images" do |image_fields| %>
<%= image_fields.fields_for "0" do |image_field| %>
<script>
$(document).on('click', '#add_file.title_images', function(){
var old_id = $('.image_field.title_images').eq(-1).attr('value');
if( old_id == undefined)
old_id = 0;
else
old_id = Number(old_id);
var new_id = old_id + 1;
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => 0}).gsub("\"","\'").html_safe %>"
$(this).parent().siblings('.add-target.title_images').before(('<div class="image_field title_images" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
var name = $('.image_field.title_images').eq(-1).find('[type="file"]').attr('name');
$('.image_field.title_images').eq(-1).find('[type="file"]').attr('name',name.replace("0",new_id-1));
name = $('.image_field.title_images').eq(-1).find('input.sort_num').attr('name');
$('.image_field.title_images').eq(-1).find('input.sort_num').attr('name',name.replace("0",new_id-1));
new_id = $('.image_field.title_images').eq(-2).find('input.sort_num').val();
if(new_id != undefined)
$('.image_field.title_images').eq(-1).find('input.sort_num').val(Number(new_id)+1);
else
$('.image_field.title_images').eq(-1).find('input.sort_num').val(1);
formTip();
});
</script>
<% end %>
<% end %>
<% end %>
<div class="add-target title_images"></div>
<p class="add-btn">
<%= hidden_field_tag 'title_images_count', @title_images.count %>
<a id="add_file" class="title_images trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t('coloncancerpredict1.add_image') %></a>
</p>
<span class="show_span"><%= t('coloncancerpredict1.tool_head_pictures') %></span>
<div style="clear:both;"></div>
<% if @head_images.length != 0%>
<% @head_images.each_with_index do |temp_image,i| %>
<%= form.fields_for "head_images" do |image_fields| %>
<div class="head_images image_field" value="<%=(i+1).to_s%>">
<%= image_fields.fields_for i.to_s do |image_field| %>
<%= render :partial => 'image_form', :object => temp_image, :locals => {:f => image_field, :i => i} %>
<% if i.to_i == @head_images.length - 1%>
<script>
$(document).on('click', '#add_file.head_images', function(){
var old_id = $('.image_field').eq(-1).attr('value');
if( old_id == undefined)
old_id = 0;
else
old_id = Number(old_id);
var new_id = old_id + 1;
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => i}).gsub("\"","\'").html_safe %>"
$(this).parent().siblings('.add-target.head_images').before(('<div class="image_field" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
var name = $('.image_field').eq(-1).find('[type="file"]').attr('name');
$('.image_field').eq(-1).find('[type="file"]').attr('name',name.replace("<%=i%>",new_id-1));
name = $('.image_field').eq(-1).find('input.sort_num').attr('name');
$('.image_field').eq(-1).find('input.sort_num').attr('name',name.replace("<%=i%>",new_id-1));
new_id = $('.image_field').eq(-2).find('input.sort_num').val();
$('.image_field').eq(-1).find('input.sort_num').val(Number(new_id)+1);
formTip();
});
</script>
<% end %>
<% end %>
<% end %>
<% end %>
<% else %>
<%= form.fields_for "head_images" do |image_fields| %>
<%= image_fields.fields_for "0" do |image_field| %>
<script>
$(document).on('click', '#add_file.head_images', function(){
var old_id = $('.image_field.head_images').eq(-1).attr('value');
if( old_id == undefined)
old_id = 0;
else
old_id = Number(old_id);
var new_id = old_id + 1;
var html = "<%= escape_javascript(render :partial => 'image_form', :object => @head_new_image, :locals => {:f => image_field, :i => 0}).gsub("\"","\'").html_safe %>"
$(this).parent().siblings('.add-target.head_images').before(('<div class="image_field head_images" value="'+new_id+'">'+html.replace(old_id, new_id)+'</div>'));
var name = $('.image_field.head_images').eq(-1).find('[type="file"]').attr('name');
$('.image_field.head_images').eq(-1).find('[type="file"]').attr('name',name.replace("0",new_id-1));
name = $('.image_field.head_images').eq(-1).find('input.sort_num').attr('name');
$('.image_field.head_images').eq(-1).find('input.sort_num').attr('name',name.replace("0",new_id-1));
new_id = $('.image_field.head_images').eq(-2).find('input.sort_num').val();
if(new_id != undefined)
$('.image_field.head_images').eq(-1).find('input.sort_num').val(Number(new_id)+1);
else
$('.image_field.head_images').eq(-1).find('input.sort_num').val(1);
formTip();
});
</script>
<% end %>
<% end %>
<% end %>
<div class="add-target head_images"></div>
<p class="add-btn">
<%= hidden_field_tag 'head_images_count', @head_images.count %>
<a id="add_file" class="head_images trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t('coloncancerpredict1.add_image') %></a>
</p>
<span class="show_span"><%= t('coloncancerpredict1.text_descibe') %></span>
<div style="clear:both;"></div>
<textarea class="ckeditor" id="coloncancerpredictfields1s_text_descibe_<%=I18n.locale.to_s%>" name="coloncancerpredictfields1s[text_descibe][<%=I18n.locale.to_s%>]">
<%= @form_to_show.text_descibe[I18n.locale.to_s] %>
</textarea>
<span class="show_span"><%= t('coloncancerpredict1.font_size') %></span>
<div style="clear:both;"></div>
<% @size=['small','medium','large'] %>
<% @size.each do |size|%>
<%= form.fields_for size do |make_size| %>
<div><label class="label_left" for=<%='font_'+size%>><%=t('coloncancerpredict1.'+size)+':'%></label><%= make_size.text_field 'font_size',{:value=> @form_to_show[size]['font_size'],:id=>'font_'+size} %>
<% if @form_to_show[size]['active'].to_i == 1%>
<%= make_size.check_box 'active',{:checked=>true,:class=>"checkbox text_choice",:style=>"float:left;"}%></div>
<% else%>
<%= make_size.check_box 'active',{:checked=>false,:class=>"checkbox text_choice",:style=>"float:left;"}%></div>
<%end%>
<%end%>
<%end%>
<span class="show_span"><%= t('coloncancerpredict1.module_mode') %></span>
<div style="clear:both;"></div>
<div class="control-group">
<label class="control-label" for="advance_mode" style="float: left; line-height: 30px;margin-right: 1em;">
<span style="float: left;"><%= t('coloncancerpredict1.advance_mode') %></span>
<button type="button" class="advance_mode_help_btn" data-target="#show_advance_mode_modal"><i aria-hidden="true" class="fa fa-question"></i></button>
</label>
<div class="controls">
<input id="advance_mode" name="<%=form.object_name%>[advance_mode]" type="checkbox" class="toggle-check" data-disabled="<%=!(form.object.advance_mode)%>">
</div>
</div>
<div style="clear:both;"></div>
<span class="show_span"><%= t('coloncancerpredict1.Input_fields') %></span>
<div style="clear:both;"></div>
<table id="fields_table" class="sort_table <%=@form_to_show.advance_mode ? 'advance_mode' : '' %>">
<% keys = Coloncancerpredictfields1s::FIELDINFO.keys - Coloncancerpredictfields1s::TherapyOnly %>
<thead>
<tr>
<th></th>
<th></th>
<% keys.each do |key|%>
<th class="<%=key%>"><%=t("coloncancerpredict1.table.#{key}")%></th>
<%end%>
</tr>
</thead>
<tbody>
<%= form.fields_for :form_show do |formfield|%>
<% @form_to_show.form_show.each do |num,property| %>
<%=formfield.fields_for num.to_s do |make_fields|%>
<%= render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>property,:num=>num,:keys => keys} %>
<%end%>
<%end%>
<%end%>
</tbody>
</table>
<button id="add_field" type="button" class="btn btn-primary"><%= t('coloncancerpredict1.table.add_field') %></button>
<div style="clear:both;"></div>
<span class="show_span"><%=t('coloncancerpredict1.table.Results')%></span>
<div style="clear:both;"></div>
<label for="form_result_is_right" style="float: left;"><%= t('coloncancerpredict1.result_is_right') %></label>
<% if @form_to_show.form_result_is_right.to_i == 1%>
<div><%= form.check_box "form_result_is_right",{:checked=>true,:class=>"checkbox",:style=>"float: left;position: relative;left: 0;transform: none!important;margin-left: 1em;",:id=>"form_result_is_right"}%></div>
<% else%>
<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%>
<div style="clear:both;"></div>
<% @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|%>
<label for="<%=item%>" style="float: left;margin-right:1em;width:11em;"><%= t('coloncancerpredict1.'+item)+':' %></label>
<% if @form_to_show[item].class == BSON::Document || @form_to_show[item].class == Hash %>
<%= form.fields_for item do |locale_fields|%>
<%= locale_fields.text_field I18n.locale.to_s,{:value=>@form_to_show[item][I18n.locale.to_s] ,:id=> item,:style=>'width:calc(100% - 16em)'} %>
<% end %>
<% else %>
<%= form.text_field item,{:value=>@form_to_show[item],:id=> item,:style=>'width:calc(100% - 16em)'} %>
<% end %>
<div style="clear:both;"></div>
<% end %>
<table id="therapies_table" class="sort_table <%=@form_to_show.advance_mode ? 'advance_mode' : '' %>">
<thead>
<tr>
<th></th>
<th></th>
<% keys = Coloncancerpredictfields1s::TherapyFields %>
<% keys.each do |key,vlaue|%>
<th class="<%=key%>"><%=t("coloncancerpredict1.table.#{key}")%></th>
<%end%>
</tr>
</thead>
<tbody>
<%= form.fields_for :form_show_in_result do |formfield|%>
<% @form_to_show.form_show_in_result.each do |num,property| %>
<%=formfield.fields_for num.to_s do |make_fields|%>
<%= render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>property,:num=>num,:keys => Coloncancerpredictfields1s::TherapyFields} %>
<%end%>
<%end%>
<%end%>
</tbody>
</table>
<button id="add_therapy" type="button" class="btn btn-primary"><%= t('coloncancerpredict1.table.add_therapy') %></button>
<div style="clear:both;"></div>
<span class="show_span"><%=t('coloncancerpredict1.table.calculate_settings')%></span>
<div style="clear:both;"></div>
<div class="control-group">
<div class="control-label" style="float: left;margin-right: 1em;width: 11em;">
<label><%= t('coloncancerpredict1.hidden_variables') %></label>
</div>
<div class="controls">
<%= form.text_area :hidden_variables, :rows=>"5", :style=> 'width: 100%;font-family: sans-serif;' %>
</div>
</div>
<div style="clear:both;"></div>
<div class="control-group">
<div class="control-label" style="float: left;margin-right: 1em;width: 11em;">
<label><%= t('coloncancerpredict1.table.prediction_formula') %></label>
</div>
<div class="controls">
<%= form.text_area :prediction_formula, :rows=>"5", :style=> 'width: 100%;font-family: sans-serif;' %>
</div>
</div>
<div id="years_settings">
<% years = @form_to_show.years %>
<% years.each_with_index do |year,i| %>
<div data-year="<%= year.to_s.strip %>">
<div class="control-label" style="float: left;margin-right: 1em;width: 13em;">
<label style="font-family: sans-serif;"><%=t("coloncancerpredict1.Overall_Survival")%>(t=<%=year%> Year)</label>
</div>
<div class="controls">
<textarea name="<%= form.object_name %>[years_settings][]" style= "width: calc(100% - 16em);" value="<%= @form_to_show.years_settings[i] rescue '' %>"><%= @form_to_show.years_settings[i] rescue '' %></textarea>
</div>
</div>
<% end %>
</div>
<%=form.submit "#{t(:updatefont)}",{:id=>"updatebtn"}%>
<%end%>
<link href="/assets/admin/coloncancerpredict1.css" media="screen" rel="stylesheet">
<script>
$(".advance_mode_help_btn").click(function(){
$("#show_advance_mode_modal").modal();
})
$("#show_advance_mode_modal button").click(function(){
$("#show_advance_mode_modal").modal("hide");
})
$("#advance_mode").click(function(){
if(window.confirm("<%=t('coloncancerpredict1.advance_mode_hint1').gsub("\n","\\n")%>")){
$("#fields_table,#therapies_table").toggleClass("advance_mode");
}else{
return false;
}
})
$('.text_choice').click(function(){
$('.text_choice').prop('checked' , false);
$(this).prop('checked' , true);
});
$("#add_field").click(function(){
var index = $("#fields_table tbody tr").length.toString();
<%= fields_for :coloncancerpredictfields1s do |form|%>
<%= form.fields_for :form_show do |formfield|%>
<%=formfield.fields_for :new_index do |make_fields|%>
<% keys = Coloncancerpredictfields1s::FIELDINFO.keys - Coloncancerpredictfields1s::TherapyOnly %>
var html = "<%= "#{render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>{},:num=>'',:keys => keys}}".gsub(/(\r\n|\n)/,"").gsub("\"","\\\"").html_safe %>";
$("#fields_table tbody").append(html.replaceAll('new_index',index));
<% end %>
<% end %>
<% end %>
$(".remove_div").off("click").on("click",function(){
$el = $(this).parent().siblings("tr").not($(this)).eq(0);
$(this).parent().remove();
update_key($el);
})
})
$("#add_therapy").click(function(){
var index = $("#therapies_table tbody tr").length.toString();
<%= fields_for :coloncancerpredictfields1s do |form|%>
<%= form.fields_for :form_show_in_result do |formfield|%>
<%=formfield.fields_for :new_index do |make_fields|%>
<% keys = Coloncancerpredictfields1s::TherapyFields %>
var html = "<%= "#{render :partial => 'form', :locals=>{:make_fields=>make_fields,:property=>{},:num=>'',:keys => keys}}".gsub(/(\r\n|\n)/,"").gsub("\"","\\\"").html_safe %>";
$("#therapies_table tbody").append(html.replaceAll('new_index',index));
<% end %>
<% end %>
<% end %>
$(".remove_div").off("click").on("click",function(){
$el = $(this).parent().siblings("tr").not($(this)).eq(0);
$(this).parent().remove();
update_key($el);
})
})
function update_key(ele){
console.log($(ele))
var ui_child=$(ele).parent().find('> tr');
console.log(ui_child);
for (var i=0;i<ui_child.length;i++){
var now_ele = ui_child.eq(i);
var $inputs = now_ele.find('input');
$inputs.each(function(input_index,input){
var name = input.name;
name = $.map(name.split(/(\[|\])/),function(v,ii){
var vv = v;
var num = Number.parseInt(vv);
if(!Number.isNaN(num)){
vv = i.toString();
}
return vv;
}).join("");
console.log(name)
input.name = name;
})
}
}
$( ".sort_table > tbody" ).sortable({
axis: "y",
revert: true,
placeholder: "sortable-placeholder",
handle: ".sort_div",
update: function(event, ui) {
update_key($(ui.item[0]))
}
});
$(".remove_div").click(function(){
$el = $(this).parent().siblings("tr").not($(this)).eq(0);
$(this).parent().remove();
update_key($el);
})
$(".remove_existing_record").click(function(){
if(window.confirm("Are you sure want to remove this file?")){
$(this).find(".should_destroy").val("1");
$(this).parent().siblings(".file-link").remove();
}
})
$("#years").on('blur',function(){
var years = [];
try{
years = $(this).val().split(/\[|,|\]/).filter(function(aa){return aa !="" && aa != undefined}).map(function(aa){return aa.trim()});
}catch(e){};
var index = 0;
years.forEach(function(year){
if($("#years_settings [data-year='"+year+"']").length == 0){
var year_text = ('<div data-year="'+year+'">'+
'<div class="control-label" style="float: left;margin-right: 1em;width: 13em;">'+
'<label style="font-family: sans-serif;"><%=t("coloncancerpredict1.Overall_Survival")%>(t='+year+' Year)</label>'+
'</div>'+
'<div class="controls">'+
'<textarea name="coloncancerpredictfields1s[years_settings][]" style= "width: calc(100% - 16em);"></textarea>'+
'</div>'+
'</div>');
if(index != 0){
$("#years_settings [data-year='"+years[index - 1]+"']").after(year_text);
}else{
$("#years_settings").html(year_text+$("#years_settings").html());
}
}
index++;
})
var all_years = $("#years_settings [data-year]").map(function(i,aa){return $(aa).attr("data-year").toString().trim() }).toArray();
all_years.forEach(function(a_year){
if(years.indexOf(a_year) == -1){
$("#years_settings [data-year='"+a_year+"']").remove()
}
})
})
</script>

View File

@ -0,0 +1,5 @@
<%= form_for @bulletin, url: admin_announcements_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render :partial => 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,150 @@
<style type="text/css">
#notification{
background-color: #ececec;
font-size: 14px;
left: 40%;
padding: 10px;
position: absolute;
text-align: center;
top: 40px;
width: auto;
z-index: 1200;
display: none;
}
.badge-info{
margin-left: 10px;
}
#approver-list{
list-style: none;
margin-left: 5px;
}
#approver-list li {
border-bottom: 1px solid #efefef;
margin-bottom: 10px;
padding-bottom: 10px;
}
#approver-list .approver-avatar{
width: 60px;
height: 60px;
border-radius: 50px;
margin-right: 20px;
}
#approver-list .approver-check{
vertical-align: middle;
margin-top: 25px;
}
#approver-list .approver-check input{
margin-right: 5px;
vertical-align: middle;
}
#approver-list .approver-check label{
display: inline;
vertical-align: middle;
}
#approver-list .approver-title{
font-size: 14px;
}
</style>
<%
sub_managers = @module_app.sub_managers
sub_managers.delete(nil)
%>
<div id="notification"><%= t("announcement.click_on_submit") %></div>
<%= form_for @setting, url: (@setting.new_record? ? admin_announcement_createsettings_path : admin_announcement_updatesettings_path), html: {class: "form-horizontal main-forms"} do |f| %>
<div class="input-area">
<div class="control-group">
<%= f.label :top_limit, t("announcement.top_limit"), :class => "control-label muted" %>
<div class="controls">
<%= f.number_field :top_limit, :min => "0" %>
<span class="help-block"><%= t("announcement.for_unlimited") %></span>
</div>
</div>
<% if AnnouncementSetting.is_pro? %>
<% if !sub_managers.blank? %>
<div class="control-group">
<%= f.label "Approver Setting", :class => "control-label muted" %>
<div class="controls">
<a href="#approverModal" role="button" class="btn" data-toggle="modal"><%= t("announcement.approvers_list") %></a>
<span class="badge badge-info"><%= @setting.approvers.count %></span>
</div>
</div>
<% else %>
<div class="control-group">
<a href="/admin/authorizations/announcement"><%= t("announcement.click_set_sub_manager") %></a>
</div>
<% end %>
<div class="control-group">
<%= f.label "Send emails to", :class => "control-label muted" %>
<div class="controls">
<input type="checkbox" name="announcement_setting[email_to][]" value="admins" <%= @setting.email_to.include?("admins") ? "checked=checked" : "" %>> <%= t("admin") %>
<input type="checkbox" name="announcement_setting[email_to][]" value="managers" <%= @setting.email_to.include?("managers") ? "checked=checked" : "" %>> <%= t("manager") %>
<input type="checkbox" name="announcement_setting[email_to][]" value="approvers" <%= @setting.email_to.include?("approvers") ? "checked=checked" : "" %>> <%= t("announcement.approver") %>
</div>
</div>
</div>
<div class="hidden-approver-list">
<% sub_managers.each do |sm| %>
<% if @setting.approvers.include?(sm.id.to_s) %>
<input type="hidden" id="check_<%= sm.id.to_s %>" value="<%= sm.id.to_s %>" name="announcement_setting[approvers][]">
<% end %>
<% end %>
</div>
<% end %>
<div class="form-actions">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
</div>
<% end %>
<% if AnnouncementSetting.is_pro? %>
<div id="approverModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="approverModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="approverModalLabel"><%= t("sub_manager") %></h3>
</div>
<div class="modal-body">
<ul id="approver-list">
<% sub_managers.each do |sm| %>
<li>
<%= image_tag sm.member_profile.avatar.thumb, :class => "approver-avatar" %>
<span class="approver-title"><%= sm.name %></span>
<span class="pull-right approver-check">
<input id="checkbox_<%= sm.id %>" type="checkbox" value="<%= sm.id %>" <%= @setting.approvers.include?(sm.id.to_s) ? "checked=checked" : "" %>>
<label for="checkbox_<%= sm.id %>"><%= t("announcement.approver") %></label>
</span>
</li>
<% end %>
</ul>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Ok</button>
</div>
</div>
<script type="text/javascript">
var approverList = $(".hidden-approver-list");
$(".approver-check input").on("click",function(){
var el = $(this);
if(el.is(":checked")){
var t = $("<input type='hidden'>");
t.val(el.val());
t.attr("name", "announcement_setting[approvers][]");
t.attr("id", "check_" + el.val());
approverList.append(t);
}else{
approverList.find("#check_" + el.val()).remove();
}
})
$("#approverModal").on("hidden",function(){
$("#notification").slideDown();
$(".badge-info").text($(".hidden-approver-list input").length);
})
</script>
<% end %>

View File

@ -0,0 +1,87 @@
<link href="/assets/admin/coloncancerpredict1.css" media="print" rel="stylesheet">
<link href="/assets/admin/coloncancerpredict1.css" media="screen" rel="stylesheet">
<% if !@results[0].nil? %>
<table>
<thead>
<tr>
<th><%=((I18n.locale=="en") ? 'submit time' : '提交時間') %></th>
<% @results[0].names.each do |key,name|%>
<th><%=name[I18n.locale.to_s].to_s.html_safe %></th>
<%end%>
</tr>
</thead>
<tbody>
<% @key_len = @results[0].names.length %>
<% @results.each do |result| %>
<% if result.names.length != @key_len %>
</tbody>
</table>
<table>
<thead>
<tr>
<th><%=((I18n.locale=="en") ? 'submit time' : '提交時間') %></th>
<% result.names.each do |key,name|%>
<th><%=name[I18n.locale.to_s].to_s.html_safe %></th>
<%end%>
</tr>
</thead>
<tbody>
<% end %>
<tr>
<td><%= result.created_at %></td>
<% result.result.each do |key,value| %>
<% @key_len %>
<% if key != "locale" %>
<% if (result.values[key][I18n.locale.to_s].length == 0 rescue true) %>
<td><%= value.to_s %></td>
<% else %>
<td><% v = result.values[key][I18n.locale.to_s][value.to_i-1] rescue nil %><%= v.nil? ? value : v %></td>
<% end %>
<% end %>
<%end%>
</tr>
<%end%>
</tbody>
</table>
<% end %>
<%=@pagination.html_safe%>
<style type="text/css">
thead > tr > th{
border:1px solid;
background: bisque;
}
tbody{
background:white;
}
tbody > tr > td{
border:1px solid;
position: relative;
}
.show_li,.show_li *{
list-style:none;
color:balck;
}
.show_li ul{
display:none;
}
#clicktosee{
color:blue;
cursor:pointer;
}
.checkbox{
left: 50%;
position: absolute;
transform: translate(-50%, -50%) !important;
top: 50%;
}
#updatebtn{
margin-top: 1em;
position: fixed;
right: 1em;
background-color: rgb(210, 105, 0);
color: white;
border: 0em;
padding: 0.125em 0.5em;
border-radius: 0.5em;
}
</style>

View File

@ -0,0 +1 @@
<%= render_view %>

18
bin/rails Normal file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/coloncancerpredict1/engine', __FILE__)
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
# require 'rails/all'
# require 'rails/engine/commands'
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
require 'rails/engine/commands'
require "mongoid/railtie"

View File

@ -0,0 +1,57 @@
# -*- encoding: utf-8 -*-
# stub: coloncancerpredict1 0.0.1 ruby lib
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
if bundle_update_flag
insert_flag = 0
app_path = File.expand_path(__dir__)
template_path = ENV['PWD'] + '/app/templates'
all_template = Dir.glob(template_path+'/*/')
puts 'copying module'
check_texts = '<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.min.js"%>'
edit_texts = '<%= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"%>'
all_template.each do |folder|
if !folder.include?('mobile')
begin
if folder.split('/')[-1] != 'mobile'
begin
system ('cp -r '+ app_path + '/modules/. ' + folder+'/modules/.')
puts "finish copy module coloncancerpredict1 to #{folder}"
rescue
puts 'error copy'
end
end
texts = File.read(folder+'partial/_head.html.erb')
insert_flag = 0
if texts.include?(check_texts)
texts = texts.gsub(check_texts,edit_texts)
insert_flag = 1
end
if insert_flag == 1
puts 'editing _head.html.erb'
f = File.open(folder+'partial/_head.html.erb','w')
f.write(texts)
f.close
end
rescue
puts "not found _head.html.erb in #{folder}"
end
end
end
end
Gem::Specification.new do |s|
s.name = "coloncancerpredict1"
s.version = "0.0.1"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Ruling Digital"]
s.date = "2022-02-07"
s.description = "Colon Cancer Predict for Orbit"
s.email = ["orbit@rulingcom.com"]
s.files = ["MIT-LICENSE", "README.rdoc", "Rakefile", "app/assets/images/coloncancerpredict1", "app/assets/images/coloncancerpredict1/triangle_add.png", "app/assets/images/coloncancerpredict1/triangle_sub.png", "app/assets/javascripts/admin/coloncancerpredict1.js", "app/assets/javascripts/colon_cancer_predict1.js", "app/assets/javascripts/jquery.smartmenus.bootstrap.min.js", "app/assets/javascripts/jquery.smartmenus.min.js", "app/assets/javascripts/react.js", "app/assets/stylesheets/admin/coloncancerpredict1.css", "app/assets/stylesheets/colon_cancer_predict1.css", "app/controllers/admin/coloncancerpredict1s_controller.rb", "app/controllers/coloncancerpredict1s_controller.rb", "app/helpers/admin/coloncancerpredict1s_helper.rb", "app/models/coloncancerpredictfields1s.rb", "app/views/admin/coloncancerpredict1s", "app/views/admin/coloncancerpredict1s/_form.html.erb", "app/views/admin/coloncancerpredict1s/_form_file.html.erb", "app/views/admin/coloncancerpredict1s/_form_link.html.erb", "app/views/admin/coloncancerpredict1s/_index.html.erb", "app/views/admin/coloncancerpredict1s/index.html.erb", "app/views/admin/coloncancerpredict1s/new.html.erb", "app/views/admin/coloncancerpredict1s/settings.html.erb", "app/views/admin/coloncancerpredict1s/update.html.erb", "app/views/coloncancerpredict1s", "app/views/coloncancerpredict1s/index.html.erb", "config/locales/en.yml", "config/locales/zh_tw.yml", "config/routes.rb", "lib/coloncancerpredict1", "lib/coloncancerpredict1.rb", "lib/coloncancerpredict1/engine.rb", "lib/coloncancerpredict1/version.rb", "lib/tasks/coloncancerpredict1_tasks.rake", "test/coloncancerpredict1_test.rb", "test/controllers/admin/coloncancerpredict1s_controller_test.rb", "test/dummy", "test/dummy/README.rdoc", "test/dummy/Rakefile", "test/dummy/app", "test/dummy/app/assets", "test/dummy/app/assets/images", "test/dummy/app/assets/javascripts", "test/dummy/app/assets/javascripts/application.js", "test/dummy/app/assets/stylesheets", "test/dummy/app/assets/stylesheets/application.css", "test/dummy/app/controllers", "test/dummy/app/controllers/application_controller.rb", "test/dummy/app/controllers/concerns", "test/dummy/app/helpers", "test/dummy/app/helpers/application_helper.rb", "test/dummy/app/mailers", "test/dummy/app/models", "test/dummy/app/models/concerns", "test/dummy/app/views", "test/dummy/app/views/layouts", "test/dummy/app/views/layouts/application.html.erb", "test/dummy/bin", "test/dummy/bin/bundle", "test/dummy/bin/rails", "test/dummy/bin/rake", "test/dummy/config", "test/dummy/config.ru", "test/dummy/config/application.rb", "test/dummy/config/boot.rb", "test/dummy/config/environment.rb", "test/dummy/config/environments", "test/dummy/config/environments/development.rb", "test/dummy/config/environments/production.rb", "test/dummy/config/environments/test.rb", "test/dummy/config/initializers", "test/dummy/config/initializers/backtrace_silencers.rb", "test/dummy/config/initializers/cookies_serializer.rb", "test/dummy/config/initializers/filter_parameter_logging.rb", "test/dummy/config/initializers/inflections.rb", "test/dummy/config/initializers/mime_types.rb", "test/dummy/config/initializers/session_store.rb", "test/dummy/config/initializers/wrap_parameters.rb", "test/dummy/config/locales", "test/dummy/config/locales/en.yml", "test/dummy/config/routes.rb", "test/dummy/config/secrets.yml", "test/dummy/lib", "test/dummy/lib/assets", "test/dummy/log", "test/dummy/public", "test/dummy/public/404.html", "test/dummy/public/422.html", "test/dummy/public/500.html", "test/dummy/public/favicon.ico", "test/helpers/admin/coloncancerpredict1s_helper_test.rb", "test/integration/navigation_test.rb", "test/test_helper.rb"]
s.homepage = "http://www.rulingcom.com"
s.licenses = ["MIT"]
s.rubygems_version = "2.2.2"
s.summary = "Cancer_Predict for Orbit"
s.test_files = ["test/coloncancerpredict1_test.rb", "test/dummy", "test/dummy/README.rdoc", "test/dummy/bin", "test/dummy/bin/bundle", "test/dummy/bin/rake", "test/dummy/bin/rails", "test/dummy/log", "test/dummy/app", "test/dummy/app/assets", "test/dummy/app/assets/javascripts", "test/dummy/app/assets/javascripts/application.js", "test/dummy/app/assets/images", "test/dummy/app/assets/stylesheets", "test/dummy/app/assets/stylesheets/application.css", "test/dummy/app/mailers", "test/dummy/app/helpers", "test/dummy/app/helpers/application_helper.rb", "test/dummy/app/controllers", "test/dummy/app/controllers/application_controller.rb", "test/dummy/app/controllers/concerns", "test/dummy/app/views", "test/dummy/app/views/layouts", "test/dummy/app/views/layouts/application.html.erb", "test/dummy/app/models", "test/dummy/app/models/concerns", "test/dummy/Rakefile", "test/dummy/lib", "test/dummy/lib/assets", "test/dummy/public", "test/dummy/public/422.html", "test/dummy/public/500.html", "test/dummy/public/favicon.ico", "test/dummy/public/404.html", "test/dummy/config.ru", "test/dummy/config", "test/dummy/config/environments", "test/dummy/config/environments/production.rb", "test/dummy/config/environments/development.rb", "test/dummy/config/environments/test.rb", "test/dummy/config/environment.rb", "test/dummy/config/boot.rb", "test/dummy/config/routes.rb", "test/dummy/config/application.rb", "test/dummy/config/secrets.yml", "test/dummy/config/locales", "test/dummy/config/locales/en.yml", "test/dummy/config/initializers", "test/dummy/config/initializers/wrap_parameters.rb", "test/dummy/config/initializers/cookies_serializer.rb", "test/dummy/config/initializers/mime_types.rb", "test/dummy/config/initializers/inflections.rb", "test/dummy/config/initializers/backtrace_silencers.rb", "test/dummy/config/initializers/filter_parameter_logging.rb", "test/dummy/config/initializers/session_store.rb", "test/test_helper.rb", "test/helpers/admin/coloncancerpredict1s_helper_test.rb", "test/controllers/admin/coloncancerpredict1s_controller_test.rb", "test/integration/navigation_test.rb"]
s.installed_by_version = "2.2.2" if s.respond_to? :installed_by_version
end

69
config/locales/en.yml Normal file
View File

@ -0,0 +1,69 @@
en:
module_name:
coloncancerpredict1: Predict Colon Cancer Tool - Model 1
coloncancerpredict1:
hidden_variables: "Hidden Variables"
advance_mode_hint1: "After opening advance modecalculation will change!\nAre you sure switch to advance mode?"
advance_mode_hint2: "一般模式: 選項設定在計算時對應到的值由1開始。(例如: 選項設定為[\"是\",\"否\"],則\"是\"在計算時對應到1而\"否\"在計算時對應到2)。<br><hr class=\"solid_line_hr\">進階模式: 選項設定在計算時對應到的值由0開始。<br>而若開啟選項值從大到小則0對應到選項設定中的最後一項。<br>選項對應到的值的意思為當前述的計算值為0時則對應到定義的Array的第1個元素的值以此類推。<br>欄位對應檔案可上傳一個csv檔案在計算時會先依照csv中的第1直行找到對應的變數1(生成的變數名稱為csv中的第1列)的值,其餘生成的變數值則為對應之後的同一橫列的值。"
module_mode: Module Mode
advance_mode: Advance Mode
Overall_Survival: Overall Survival
coloncancerpredict1: Adjust the predict colon cancer tool - Model 1
submitResult: see submit results of the users
result_is_right: Is therapy choices in the right hand side of result block?
text_descibe: text descibe
font_size: font size
small: small
medium: medium
large: large
Input_fields: User input fields' contents
tool_head_pictures: All the logos in the page of predict tool
sort_num: sort num
logo: logo image
title: title of the page of predict tool
title_text: title texts
add_image: add image
years: Years
table_above_texts: Texts above table
text_above_texts: Texts above text
surgery_only_texts: Surgery only texts
extra_texts: Extra texts
extra_therapy_texts: Extra therapy texts
danger_texts: Warning texts
texts_between_Result_and_result_block: Texts between "Result" and "Result block"
prev_page: Previous page
next_page: Next page
export_colon_cancer_predict1_tool_records: Export cancer predict tool records
table:
welcome: Welcome to The after colon cancer healing system of Taiwanprepare!\nTo start, please enter the relevant information below.
Reset: Reset
Submit: Submit
age: Age at diagnosis
Menopausal: Post Menopausal?
ER: ER status
HER2: HER2 status
PR: PR status
Tumoursize: Tumour size(mm)
Tumourgrade: Tumour grade
lymphnodes: lymph nodes
positive: positive
negative: negative
yes: yes
no: no
unknown: unknown
Results: Results
Treatment: Treatment
Additional_Benefit: Additional Benefit
Overall_Survival: Overall Survival(%)
Surgeryonly: Surgery only
Hormonetherapy: Hormone therapy
Chemotherapy: Chemotherapy
years: years
result: Results
table: Table
curve: Curves
text: Texts
Therapy_choice: Treatment options
lpv_impact: "lpv Impact(Input: Float)"
active_choice: "Active choice(input 1 present choice 1 is regarded as therapy enable)"
disable_condition: "Disable Condition"

85
config/locales/zh_tw.yml Normal file
View File

@ -0,0 +1,85 @@
zh_tw:
module_name:
coloncancerpredict1: 大腸癌線上預測工具-Model 1
coloncancerpredict1:
hidden_variables: "隱藏的變數"
advance_mode_hint1: "開啟進階模式後,計算方式有差異。\n您確定要開啟進階模式?"
advance_mode_hint2: "一般模式: 選項設定在計算時對應到的值由1開始。(例如: 選項設定為[\"是\",\"否\"],則\"是\"在計算時對應到1而\"否\"在計算時對應到2)。<br><hr class=\"solid_line_hr\">進階模式: 選項設定在計算時對應到的值由0開始。<br>而若開啟選項值從大到小則0對應到選項設定中的最後一項。<br>選項對應到的值的意思為當前述的計算值為0時則對應到定義的Array的第1個元素的值以此類推。<br>欄位對應檔案可上傳一個csv檔案在計算時會先依照csv中的第1直行找到對應的變數1(生成的變數名稱為csv中的第1列)的值,其餘生成的變數值則為對應之後的同一橫列的值。"
module_mode: 模組模式
advance_mode: 進階模式
Overall_Survival: 總生存率
coloncancerpredict1: 大腸癌線上預測工具調整-Model 1
submitResult: 查看用戶繳交表單結果
result_is_right: 治療選項在結果的右邊?
text_descibe: 文字說明
font_size: 字體
small:
medium:
large:
Input_fields: 使用者輸入欄位內容
tool_head_pictures: 預測工具頁面最上方的所有logo
sort_num: 順序號碼
logo: logo圖片
title: 預測工具頁面標題
title_text: 標題文字
add_image: 新增圖片
years:
table_above_texts: 在表格上方的文字
text_above_texts: 在文字區塊上方的文字
surgery_only_texts: 純手術的文字
extra_texts: 額外文字
extra_therapy_texts: 額外治療的文字
danger_texts: 警告文字
texts_between_Result_and_result_block: 在"結果"和"結果區塊"之間的文字
prev_page: 上一頁
next_page: 下一頁
export_colon_cancer_predict1_tool_records: 匯出大腸癌預測系統的使用者紀錄
table:
welcome: 歡迎使用台灣準備大腸癌癒後系統!\n若要開始 請在下方輸入相關資訊
Reset: 重置
Submit: 送出
age: 確認年齡
Menopausal: 更年期狀態
ER: ER狀態
HER2: HER2狀態
PR: PR狀態
Tumoursize: 腫瘤大小(mm)
Tumourgrade: 腫瘤分級
lymphnodes: 淋巴結數目
positive: 陽性
negative: 陰性
yes:
no:
unknown: 未知
Results: 結果
Treatment: 治療
Additional_Benefit: 額外治療效益
Overall_Survival: 總生存率(%)
Surgeryonly: 純手術
Hormonetherapy: 賀爾蒙治療
Chemotherapy: 化學治療
years:
result: 結果
table: 列表
curve: 曲線
text: 文字
Therapy_choice: 治療選項
variable: 變數名稱
name: 名稱
is_num: 數字欄位
hint: 提示文字
comment_text: 說明文字
choice_fields: '選項設定([]代表無選項)'
range: '數字範圍設定([]代表無範圍限制)'
right: 顯示在右側
is_float: 可輸入小數
revert_value: 選項值從大到小(ex:有兩個選項則選項值依序為1和0)
map_values: 選項對應到的值(若無,則會使用初始值)
coloncancer_predict_mapping_file1: 欄位對應檔案
calculate_settings: 計算設定
prediction_formula: 預測公式
add_field: 新增填寫欄位
add_therapy: 新增治療選項
lpv_impact: "lpv 影響(輸入浮點數)"
active_choice: "啟用治療選項(輸入1代表第1個選項視為啟用治療)"
disable_condition: "禁用條件"

25
config/routes.rb Normal file
View File

@ -0,0 +1,25 @@
Rails.application.routes.draw do
Thread.new do
c = Coloncancerpredictfields1s.last
if c
sleep(5)
c.save
c.auto_write_predict_js
end
end
locales = Site.first.in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do
get 'coloncancerpredict1s' , to: 'coloncancerpredict1s#index'
get 'editColoncancerpredict1s' , to: 'coloncancerpredict1s#edit'
post 'editColoncancerpredict1s' , to: 'coloncancerpredict1s#edit'
patch 'editColoncancerpredict1s' , to: 'coloncancerpredict1s#edit'
get 'coloncancerpredict1s/showSubmit' , to: 'coloncancerpredict1s#showSubmit'
get 'coloncancerpredict1s/export_cancer_tool_record' , to: 'coloncancerpredict1s#export_cancer_tool_record'
resources :coloncancerpredict1s
end
get "coloncancerpredict1Result", to: "coloncancerpredict1s#calculate"
post "coloncancerpredict1Result", to: "coloncancerpredict1s#calculate"
end
end

View File

@ -0,0 +1,4 @@
require "coloncancerpredict1/engine"
module Coloncancerpredict1
end

View File

@ -0,0 +1,39 @@
require "yaml"
module Coloncancerpredict1
class Engine < ::Rails::Engine
initializer "coloncancerpredict1" do
OrbitApp.registration "Coloncancerpredict1", :type => "ModuleApp" do
base_url File.expand_path File.dirname(__FILE__)
taggable "coloncancerpredictfields1s"
categorizable
authorizable
widget_methods ["widget"]
widget_settings [{"data_count"=>1}]
set_keyword_contstraints ['coloncancerpredict1Result']
frontend_enabled
side_bar do
head_label_i18n 'coloncancerpredict1.coloncancerpredict1', icon_class: "icons-megaphone"
available_for "users"
active_for_controllers (['admin/coloncancerpredict1s'])
head_link_path "admin_coloncancerpredict1s_path"
context_link 'coloncancerpredict1.coloncancerpredict1',
:link_path=>"admin_coloncancerpredict1s_path" ,
:priority=>1,
:active_for_action=>{'admin/coloncancerpredict1s'=>'index'},
:available_for => 'users'
context_link 'coloncancerpredict1.submitResult',
:link_path=>"admin_coloncancerpredict1s_showSubmit_path" ,
:priority=>1,
:active_for_action=>{'admin/coloncancerpredict1s'=>'show_submit'},
:available_for => 'users'
context_link 'coloncancerpredict1.export_colon_cancer_predict1_tool_records',
:link_path=>"admin_coloncancerpredict1s_export_cancer_tool_record_path" ,
:priority=>1,
:active_for_action=>{'admin/coloncancerpredict1s'=>'export_cancer_tool_record'},
:available_for => 'users'
end
end
end
end
end

View File

@ -0,0 +1,3 @@
module Coloncancerpredict1
VERSION = "0.0.1"
end

View File

@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :coloncancerpredict1 do
# # Task goes here
# end

View File

@ -0,0 +1,7 @@
<script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/colon_cancer_predict1.js"></script>
{{table}}
<%= stylesheet_link_tag "colon_cancer_predict1", media: "screen" %>
<%= stylesheet_link_tag "bootstrap.min.print", media: "print" %>
<%= stylesheet_link_tag "colon_cancer_predict1_print", media: "print" %>

View File

@ -0,0 +1,7 @@
<script type="text/javascript" src="/assets/jquery.smartmenus.min.js"></script>
<script type="text/javascript" src="/assets/jquery.smartmenus.bootstrap.min.js"></script>
<script type="text/javascript" src="/assets/colon_cancer_predict1.js"></script>
{{table}}
<%= stylesheet_link_tag "colon_cancer_predict1", media: "screen" %>
<%= stylesheet_link_tag "bootstrap.min.print", media: "print" %>
<%= stylesheet_link_tag "colon_cancer_predict1_print", media: "print" %>

View File

@ -0,0 +1,22 @@
{
"frontend": [
{
"filename" : "colon_cancer_predict1_index",
"name" : {
"zh_tw" : "1. 大腸癌線上預測工具-Model 1",
"en" : "1. Colon cancer predict tool-Model 1"
},
"thumbnail" : "thumb.png"
}
],
"widgets" : [
{
"filename" : "colon_cancer_predict1_widget",
"name" : {
"zh_tw" : "1. 大腸癌線上預測工具-Model 1",
"en" : "1. Colon cancer predict tool-Model 1"
},
"thumbnail" : "thumb.png"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

1
reset_btn.txt Normal file
View File

@ -0,0 +1 @@
QG(function (a) { a = null != a && (a.v & 64 || h === a.J) ? P(Fi, a) : a; a = y.h(a, nu); console.log(a);return React.createElement("button", { onClick: a, className: "btn navbar-btn btn-danger btn-lg screen-only" }, " Reset ") }, new R(null, 1, 5, S, [ZG], null), "clear-all-button")

View File

@ -0,0 +1,7 @@
require 'test_helper'
class Coloncancerpredict1Test < ActiveSupport::TestCase
test "truth" do
assert_kind_of Module, Bulletin
end
end

View File

@ -0,0 +1,14 @@
require 'test_helper'
class Admin::Coloncancerpredict1sControllerTest < ActionController::TestCase
test "should get new" do
get :new
assert_response :success
end
test "should get create" do
get :create
assert_response :success
end
end

28
test/dummy/README.rdoc Normal file
View File

@ -0,0 +1,28 @@
== README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
Please feel free to use a different markup language if you do not plan to run
<tt>rake doc:app</tt>.

6
test/dummy/Rakefile Normal file
View File

@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks

View File

View File

@ -0,0 +1,13 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require_tree .

View File

@ -0,0 +1,15 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/

View File

@ -0,0 +1,5 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end

View File

@ -0,0 +1,2 @@
module ApplicationHelper
end

View File

View File

View File

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<title>Dummy</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
</head>
<body>
<%= yield %>
</body>
</html>

3
test/dummy/bin/bundle Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

4
test/dummy/bin/rails Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

4
test/dummy/bin/rake Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run

4
test/dummy/config.ru Normal file
View File

@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application

View File

@ -0,0 +1,29 @@
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
# require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
Bundler.require(*Rails.groups)
require "bulletin"
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
end
end

View File

@ -0,0 +1,5 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)

View File

@ -0,0 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!

View File

@ -0,0 +1,34 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end

View File

@ -0,0 +1,80 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs.
config.assets.digest = true
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Set to :debug to see everything in the log.
config.log_level = :info
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# config.assets.precompile += %w( search.js )
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
end

View File

@ -0,0 +1,39 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance.
config.serve_static_assets = true
config.static_cache_control = 'public, max-age=3600'
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end

View File

@ -0,0 +1,7 @@
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View File

@ -0,0 +1,3 @@
# Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :json

View File

@ -0,0 +1,4 @@
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]

View File

@ -0,0 +1,16 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end

View File

@ -0,0 +1,5 @@
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone

View File

@ -0,0 +1,3 @@
# Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_dummy_session'

View File

@ -0,0 +1,9 @@
# Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end

View File

@ -0,0 +1,23 @@
# Files in the config/locales directory are used for internationalization
# and are automatically loaded by Rails. If you want to use locales other
# than English, add the necessary files in this directory.
#
# To use the locales, use `I18n.t`:
#
# I18n.t 'hello'
#
# In views, this is aliased to just `t`:
#
# <%= t('hello') %>
#
# To use a different locale, set it with `I18n.locale`:
#
# I18n.locale = :es
#
# This would use the information in config/locales/es.yml.
#
# To learn more, please read the Rails Internationalization guide
# available at http://guides.rubyonrails.org/i18n.html.
en:
hello: "Hello world"

View File

@ -0,0 +1,56 @@
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end

View File

@ -0,0 +1,22 @@
# Be sure to restart your server when you modify this file.
# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rake secret` to generate a secure secret key.
# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.
development:
secret_key_base: 51f457918fc204bef2280de08080b24d6289997cc1af905e47aead42b5e027b6bc27cd6cbd1cb11a34d8df4163d63db2a0ff973acfa11b239a5dd15d6bfb5bfd
test:
secret_key_base: 1a2d31f4fb35a33e52a69eac67e125b9b1ba5b302e8d3468e60282061a8e74d1a8d977fb88f2eb001aecb99c9c3fbde29e0c7c5ac5d548e1458772ee50ed48e9
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

View File

0
test/dummy/log/.keep Normal file
View File

View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>The page you were looking for doesn't exist (404)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/404.html -->
<div class="dialog">
<div>
<h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html>
<head>
<title>The change you wanted was rejected (422)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/422.html -->
<div class="dialog">
<div>
<h1>The change you wanted was rejected.</h1>
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

View File

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<title>We're sorry, but something went wrong (500)</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {
background-color: #EFEFEF;
color: #2E2F30;
text-align: center;
font-family: arial, sans-serif;
margin: 0;
}
div.dialog {
width: 95%;
max-width: 33em;
margin: 4em auto 0;
}
div.dialog > div {
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #BBB;
border-top: #B00100 solid 4px;
border-top-left-radius: 9px;
border-top-right-radius: 9px;
background-color: white;
padding: 7px 12% 0;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
h1 {
font-size: 100%;
color: #730E15;
line-height: 1.5em;
}
div.dialog > p {
margin: 0 0 1em;
padding: 1em;
background-color: #F7F7F7;
border: 1px solid #CCC;
border-right-color: #999;
border-left-color: #999;
border-bottom-color: #999;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-top-color: #DADADA;
color: #666;
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
}
</style>
</head>
<body>
<!-- This file lives in public/500.html -->
<div class="dialog">
<div>
<h1>We're sorry, but something went wrong.</h1>
</div>
<p>If you are the application owner check the logs for more information.</p>
</div>
</body>
</html>

View File

View File

@ -0,0 +1,4 @@
require 'test_helper'
class Admin::Coloncancerpredict1sHelperTest < ActionView::TestCase
end

View File

@ -0,0 +1,9 @@
require 'test_helper'
class NavigationTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end

15
test/test_helper.rb Normal file
View File

@ -0,0 +1,15 @@
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rails/test_help"
Rails.backtrace_cleaner.remove_silencers!
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
# Load fixtures from the engine
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
end