75 lines
7.2 KiB
Ruby
75 lines
7.2 KiB
Ruby
class Cancerpredictfields
|
||
include Mongoid::Document
|
||
include Mongoid::Timestamps
|
||
include OrbitModel::Status
|
||
include OrbitModel::Impression
|
||
# encoding: utf-8
|
||
include OrbitTag::Taggable
|
||
include OrbitCategory::Categorizable
|
||
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","cancer_predict_mapping_file"=>"String"}
|
||
|
||
field :title ,type:String ,default:""
|
||
field :form_show , :type=> Hash ,default:{0=>{:variable=>"sex",:name=>{"zh_tw"=>"性別<br/>(Sex)","en"=>"Sex"},:is_num=>0, :hint=>{'zh_tw'=>'','en'=>''} , :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['男','女'],"en"=>['Male','Female']},:range=>[],:right=>0,:is_float=>0,:revert_value=>0,:map_values=>[],:cancer_predict_mapping_file=>""},
|
||
1=>{:variable=>"age",:name=>{"zh_tw"=>"年齡<br/>(Age)","en"=>"Age"},:is_num=>1, :hint=>{'zh_tw'=>'從 20 歲(含)開始至 98 歲','en'=>'Age must be between 20 and 98'} , :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[20,98],:right=>0,:is_float=>0,:revert_value=>0,:map_values=>[],:cancer_predict_mapping_file=>""},
|
||
2=>{:variable=>"calcification_score",:name=>{"zh_tw"=>"鈣化指數<br/>(Calcification score)","en"=>"Calcification score"},:is_num=>1,:hint=>{'zh_tw'=>'請輸入0到5000的數字','en'=>'Please enter a number between 0 and 5000'}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>[],"en"=>[]},:range=>[0,5000],:right=>0,:is_float=>1,:revert_value=>0,:map_values=>[],:cancer_predict_mapping_file=>""}
|
||
}
|
||
field :form_show_in_result , :type=> Hash ,default:{}#{0=>{:variable=>"hormone_therapy",:name=>{"zh_tw"=>"賀爾蒙治療","en"=>"Hormone/Steroid therapy"},:is_num=>0, :hint=>{'zh_tw'=>'適用賀爾蒙受體陽性病人','en'=>'Hormone/ steroid therapy is available when ER status is positive'} , :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]},
|
||
#1=>{:variable=>"Chemotherapy",:name=>{"zh_tw"=>"化學治療","en"=>"Chemotherapy"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]},
|
||
#2=>{:variable=>"Radiotherapy",:name=>{"zh_tw"=>"放射治療","en"=>"Radiotherapy"},:is_num=>0,:hint=>{'zh_tw'=>'','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]},
|
||
#3=>{:variable=>"Targeted_therapy",:name=>{"zh_tw"=>"標靶治療","en"=>"Targeted therapy"},:is_num=>0,:hint=>{'zh_tw'=>'抗HER2治療','en'=>''}, :comment_text=>{'zh_tw'=>'','en'=>''}, :choice_fields=> {"zh_tw"=>['否','是'],"en"=>['No','Yes']},:range=>[]}
|
||
#}
|
||
field :form_result_is_right , :type=> Integer ,default: 0
|
||
field :text_descibe ,type:Hash ,default:{"zh_tw"=>"歡迎使用台灣心血管疾病預後預測系統<br />本預測系統由全民健保資料庫2017年~2019年間共1964位病人電腦斷層影像所建立之預測模型<br />請在下方填入相關資訊","en"=>"Welcome to the Taiwan Breast Cancer Prediction System!<br/>The prediction system is constructed using clinical data from 90,841 breast cancer patients in the Taiwan Cancer Registry database between 2011 to 2015, and validated using clinical data from 49,374 breast cancer patients in the U.S.-based Surveillance, Epidemiology and End Results (SEER) database. <br/>To start, please select the information below."}
|
||
field :small ,type:Hash ,default:{'font_size'=>"0.825em",'active'=>0}
|
||
field :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'=>'Cardiovascular Disease Survival Forecast in Taiwan'}
|
||
field :table_above_texts ,type:Hash ,default:{'zh_tw'=>"下表之分析為針對手術後病人,根據選定的術後治療,分別估計在半年、一年及一年半的再住院或死亡機率。",'en'=>'The analysis is for women who had undergone surgery.The table shows the 0.5-, 1- and 1.5-year survival rates,based on the treatment you have selected.'}
|
||
field :text_above_texts ,type:Hash ,default:{'zh_tw'=>"此研究分析來自於照射胸部電腦斷層所得之結果,根據您所輸入的資訊,在第{{years}}年內,有2.69%的機率可能再住院或死亡{{Surgery_only}}%。",'en'=>'此研究分析來自於照射胸部電腦斷層所得之結果,根據您所輸入的資訊,在第{{years}}年內,有2.69%的機率可能再住院或死亡{{Surgery_only}}%。'}
|
||
field :surgery_only_texts ,type:Hash ,default:{'zh_tw'=>'','en'=>''}
|
||
field :extra_texts ,type:Hash ,default:{'zh_tw'=>',此外','en'=>''}
|
||
field :extra_therapy_texts ,type:Hash ,default:{'zh_tw'=>'100 位在術後有接受{{extra_therapy}}的婦女中,有{{survival_num}}位婦女,術後{{surgery_year}}年仍為存活(多了{{Additional_Benefit}}位)','en'=>'{{survival_num}} out of 100 women treated with {{extra_therapy}} are alive (an extra {{Additional_Benefit}})'}
|
||
field :danger_texts ,type:Hash ,default:{'zh_tw'=>'請注意紅框的輸入資料是否符合要求!','en'=>'Please check whether input data in red blocks are correct!'}
|
||
field :years ,type:Array ,default:[1,1.5,2,2.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: ""
|
||
field :years_settings , type: Array , default: ["0.8095037^( exp(A) )","0.729158^( exp(A) )","0.6717211^( exp(A) )","0.6056773^( exp(A) )"]
|
||
field :mapping_data_from_csv , type: String ,default: ""
|
||
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_create :set_expire
|
||
def update_user
|
||
User.find(update_user_id) rescue nil
|
||
end
|
||
def update_user=(user)
|
||
self.update_user_id = user.id
|
||
end
|
||
def email_members
|
||
MemberProfile.find(self.email_member_ids) rescue []
|
||
end
|
||
def email_addresses
|
||
addresses = self.email_members.collect{|member| member.email} rescue []
|
||
addresses = addresses +[self.other_mailaddress] if !self.other_mailaddress.blank?
|
||
addresses.flatten
|
||
end
|
||
def email
|
||
mail = Email.find(self.email_id) rescue nil
|
||
end
|
||
def expired?
|
||
(self.deadline < Time.now) rescue false
|
||
end
|
||
def destroy_email
|
||
mail = Email.find(self.email_id) rescue nil
|
||
mail.destroy if !mail.nil?
|
||
end
|
||
def self.remove_expired_status
|
||
self.where(:is_top => true, :top_end_date.ne => nil, :top_end_date.lt => Time.now).each do |b|
|
||
b.is_top = false
|
||
b.top_end_date = nil
|
||
b.save
|
||
end
|
||
end
|
||
end |