Class: Analysis_SR_Stage
- Inherits:
 - 
      Object
      
        
- Object
 - Analysis_SR_Stage
 
 
- Defined in:
 - lib/analysis_sr_stage.rb
 
Overview
Information about a systematic review on specific stage
Instance Attribute Summary collapse
- 
  
    
      #sr  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute sr.
 - 
  
    
      #stage  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute stage.
 
Instance Method Summary collapse
- #cd_accepted_id ⇒ Object
 - #cd_id_assigned_by_user(user_id) ⇒ Object
 - #cd_rejected_id ⇒ Object
 - #cd_resolved_id ⇒ Object
 - 
  
    
      #cd_screened_id  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Canonical document id for document screened on certain stage it should be noted that documents could be partially screened, not necessarily resolved.
 - #cd_without_abstract ⇒ Object
 - 
  
    
      #cd_without_allocations  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Check what Canonical documents aren’t assigned yet.
 - 
  
    
      #decisions_by_cd  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Number of decisions by cd.
 - #empty_decisions_hash ⇒ Object
 - #incoming_citations(cd_id) ⇒ Object
 - 
  
    
      #initialize(sr, stage)  ⇒ Analysis_SR_Stage 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Analysis_SR_Stage.
 - #outcoming_citations(cd_id) ⇒ Object
 - #resolutions_by_cd ⇒ Object
 - #resolutions_commentary_by_cd ⇒ Object
 - #stage_complete? ⇒ Boolean
 
Constructor Details
#initialize(sr, stage) ⇒ Analysis_SR_Stage
Returns a new instance of Analysis_SR_Stage.
      35 36 37 38  | 
    
      # File 'lib/analysis_sr_stage.rb', line 35 def initialize(sr,stage) @sr=sr @stage=stage.to_sym end  | 
  
Instance Attribute Details
#sr ⇒ Object (readonly)
Returns the value of attribute sr.
      33 34 35  | 
    
      # File 'lib/analysis_sr_stage.rb', line 33 def sr @sr end  | 
  
#stage ⇒ Object (readonly)
Returns the value of attribute stage.
      34 35 36  | 
    
      # File 'lib/analysis_sr_stage.rb', line 34 def stage @stage end  | 
  
Instance Method Details
#cd_accepted_id ⇒ Object
      111 112 113  | 
    
      # File 'lib/analysis_sr_stage.rb', line 111 def cd_accepted_id resolutions_by_cd.find_all {|v| v[1]=='yes'}.map {|v| v[0]} end  | 
  
#cd_id_assigned_by_user(user_id) ⇒ Object
      63 64 65 66  | 
    
      # File 'lib/analysis_sr_stage.rb', line 63 def cd_id_assigned_by_user(user_id) cds=@sr.cd_id_by_stage(@stage) (AllocationCd.where(:systematic_review_id=>@sr.id, :stage=>@stage.to_s, :user_id=>user_id).map(:canonical_document_id)) & cds end  | 
  
#cd_rejected_id ⇒ Object
      108 109 110  | 
    
      # File 'lib/analysis_sr_stage.rb', line 108 def cd_rejected_id resolutions_by_cd.find_all {|v| v[1]=='no'}.map {|v| v[0]} end  | 
  
#cd_resolved_id ⇒ Object
      105 106 107  | 
    
      # File 'lib/analysis_sr_stage.rb', line 105 def cd_resolved_id resolutions_by_cd.find_all {|v| (v[1]=='no' or v[1]=='yes')}.map {|v| v[0]} end  | 
  
#cd_screened_id ⇒ Object
Canonical document id for document screened on certain stage it should be noted that documents could be partially screened, not necessarily resolved
      100 101 102 103  | 
    
      # File 'lib/analysis_sr_stage.rb', line 100 def cd_screened_id cds=@sr.cd_id_by_stage(@stage) Decision.where(:systematic_review_id=>@sr.id, :canonical_document_id=>cds, :user_id=>@sr.group_users.map {|u| u[:id]}, :stage=>@stage.to_s).group(:canonical_document_id).map(:canonical_document_id) end  | 
  
#cd_without_abstract ⇒ Object
      138 139 140  | 
    
      # File 'lib/analysis_sr_stage.rb', line 138 def cd_without_abstract CanonicalDocument.where(id:@sr.cd_id_by_stage(@stage)).where(Sequel.lit("abstract IS NULL OR abstract=''")) end  | 
  
#cd_without_allocations ⇒ Object
Check what Canonical documents aren’t assigned yet
      68 69 70 71 72  | 
    
      # File 'lib/analysis_sr_stage.rb', line 68 def cd_without_allocations cds=@sr.cd_id_by_stage(@stage) assignations=AllocationCd.where(:systematic_review_id=>@sr.id, :stage=>@stage.to_s).group(:canonical_document_id, :user_id).map(:canonical_document_id).uniq CanonicalDocument.where(:id=>cds-assignations) end  | 
  
#decisions_by_cd ⇒ Object
Number of decisions by cd
      115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135  | 
    
      # File 'lib/analysis_sr_stage.rb', line 115 def decisions_by_cd cds=@sr.cd_id_by_stage(@stage) decisions=Decision.where(:systematic_review_id=>@sr.id, :canonical_document_id=>cds, :user_id=>@sr.group_users.map {|u| u[:id]}, :stage=>@stage.to_s).group_and_count(:canonical_document_id, :decision).all n_jueces_por_cd=AllocationCd.where(:systematic_review_id=>@sr.id, :canonical_document_id=>cds, :stage=>@stage.to_s).group_and_count(:canonical_document_id).as_hash(:canonical_document_id) # n_jueces=@sr.group_users.count cds.inject({}) {|ac,v| ac[v]=empty_decisions_hash ac[v]=ac[v].merge decisions.find_all {|dec| dec[:canonical_document_id]==v } .inject({}) {|ac1,v1| ac1[v1[:decision]]=v1[:count]; ac1 } suma=ac[v].inject(0) {|ac1,v1| ac1+v1[1]} n_jueces=n_jueces_por_cd[v].nil? ? 0 : n_jueces_por_cd[v][:count] ac[v][Decision::NO_DECISION]=n_jueces-suma ac } end  | 
  
#empty_decisions_hash ⇒ Object
      94 95 96  | 
    
      # File 'lib/analysis_sr_stage.rb', line 94 def empty_decisions_hash Decision::N_EST.keys.inject({}) {|ac,v| ac[v]=0;ac } end  | 
  
#incoming_citations(cd_id) ⇒ Object
      40 41 42 43 44  | 
    
      # File 'lib/analysis_sr_stage.rb', line 40 def incoming_citations(cd_id) cd_stage=@sr.cd_id_by_stage(@stage) rec=@sr.references_bw_canonical.where(:cd_end=>cd_id).map(:cd_start) rec & cd_stage end  | 
  
#outcoming_citations(cd_id) ⇒ Object
      45 46 47 48 49  | 
    
      # File 'lib/analysis_sr_stage.rb', line 45 def outcoming_citations(cd_id) cd_stage=@sr.cd_id_by_stage(@stage) rec=@sr.references_bw_canonical.where(:cd_start=>cd_id).map(:cd_end) rec & cd_stage end  | 
  
#resolutions_by_cd ⇒ Object
      74 75 76 77 78 79 80 81 82  | 
    
      # File 'lib/analysis_sr_stage.rb', line 74 def resolutions_by_cd cds=@sr.cd_id_by_stage(@stage) resolutions=Resolution.where(:systematic_review_id=>@sr.id, :canonical_document_id=>cds, :stage=>@stage.to_s).as_hash(:canonical_document_id) cds.inject({}) {|ac,v| val=resolutions[v].nil? ? Resolution::NO_RESOLUTION : resolutions[v][:resolution] ac[v]=val ac } end  | 
  
#resolutions_commentary_by_cd ⇒ Object
      84 85 86 87 88 89 90 91 92  | 
    
      # File 'lib/analysis_sr_stage.rb', line 84 def resolutions_commentary_by_cd cds=@sr.cd_id_by_stage(@stage) resolutions=Resolution.where(:systematic_review_id=>@sr.id, :canonical_document_id=>cds, :stage=>@stage.to_s).as_hash(:canonical_document_id) cds.inject({}) {|ac,v| val=resolutions[v].nil? ? nil : resolutions[v][:commentary] ac[v]=val ac } end  | 
  
#stage_complete? ⇒ Boolean
      50 51 52 53 54 55 56 57 58 59 60 61 62  | 
    
      # File 'lib/analysis_sr_stage.rb', line 50 def stage_complete? #$log.info(stage) if @stage==:search bds=@sr.searches_dataset bds.where(:valid=>nil).count==0 and bds.exclude(:valid=>nil).count>0 elsif [:screening_title_abstract,:screening_references,:review_full_text].include? @stage res=resolutions_by_cd res.all? {|v| v[1]=='yes' or v[1]=='no'} else raise('Not defined yet') end end  |