62 lines
2.8 KiB
Ruby
62 lines
2.8 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
|
|
field :title ,type:String ,default:""
|
|
field :form_show , :type=> Hash ,default:{"cancer_form"=>{:names=>{'age'=>{:is_num=>1, :comment_text=>{'zh_tw'=>'年齡為該婦女於確診罹患乳癌時之年齡',:en=>''}, :fields=> [],range=[18,93]},
|
|
'tumor_size'=>{:is_num=>1, :comment_text=>{'zh_tw'=>'若有多個原發腫瘤,請輸入最大尺寸之原發腫瘤',:en=>''}, :fields=> [],range=[1]},
|
|
'node-positive_ratio'=>{:is_num=>1, :comment_text=>{'zh_tw'=>'',:en=>''}, :fields=> [],range=[0,1]},
|
|
'tumor_grade'=>{:is_num=>0, :comment_text=>{'zh_tw'=>'腫瘤級數代表腫瘤組織與正常組織間的分化程度,若無分化級數資訊,請選擇“未知”選項,將以級數 1 進行預測。',:en=>''}, :fields=> ['1','2','3','未知'],range=[0,1]},
|
|
}},
|
|
# before_destroy :destroy_email
|
|
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 :delete_empty_font ,:get_font_to_store,:set_un_used_font , :set_used_font
|
|
before_update :delete_empty_font ,:get_font_to_store,:set_un_used_font , :set_used_font
|
|
before_save :delete_empty_font ,:get_font_to_store,:set_un_used_font , :set_used_font
|
|
after_update :set_config
|
|
after_save :set_config
|
|
#before_create :set_expire
|
|
def delete_empty_font
|
|
self.font_array.each do |font,istrue|
|
|
if font.strip == ""
|
|
self.font_array.delete(font)
|
|
end
|
|
end
|
|
end
|
|
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 |