Class: ReportBuilder::PrismaReport
- Inherits:
-
Object
- Object
- ReportBuilder::PrismaReport
- Defined in:
- lib/report_builder/prisma_report.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#sr ⇒ Object
readonly
Returns the value of attribute sr.
Instance Method Summary collapse
- #create_svg ⇒ Object
-
#initialize(sr, app) ⇒ PrismaReport
constructor
A new instance of PrismaReport.
- #output(format) ⇒ Object
- #output_svg ⇒ Object
- #output_svg_download ⇒ Object
- #process_information ⇒ Object
Constructor Details
#initialize(sr, app) ⇒ PrismaReport
Returns a new instance of PrismaReport
33 34 35 36 37 38 |
# File 'lib/report_builder/prisma_report.rb', line 33 def initialize(sr,app) @sr=sr @app=app @ars=AnalysisSystematicReview.new(sr) end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app
32 33 34 |
# File 'lib/report_builder/prisma_report.rb', line 32 def app @app end |
#sr ⇒ Object (readonly)
Returns the value of attribute sr
32 33 34 |
# File 'lib/report_builder/prisma_report.rb', line 32 def sr @sr end |
Instance Method Details
#create_svg ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/report_builder/prisma_report.rb', line 87 def create_svg process_information svg_file=File.path("#{app.dir_base}/config/svg/prisma.svg") svg=File.read(svg_file) svg.gsub!("%{n1}", @n_rec_database.to_s) svg.gsub!("%{n2}", @n_rec_other.to_s) svg.gsub!("%{n3}", @n_rec_non_duplicated.to_s) svg.gsub!("%{n4}", @n_rec_screened.to_s) svg.gsub!("%{n5}", @n_rec_rej_screen.to_s) svg.gsub!("%{n6}", @n_rec_full_assed.to_s) svg.gsub!("%{n7}", @n_rec_full_rej.to_s) svg.gsub!("%{n8}", @n_rec_full_ace.to_s) svg.gsub!("%{fte}", @svg_reasons) ["Identification","Screening","Eligibility","Included", "Records identified through", "database searching","Additional records identified", "through other sources", "Records after","duplicates removed", "Records screened", "Records excluded", "Full-text articles", "assessed for eligibility", "Full-text articles","excluded", "Studies included in", "qualitative synthesis"].each do |text| svg.gsub!(text, I18n::t("prisma_report.#{text}")) end svg end |
#output(format) ⇒ Object
72 73 74 |
# File 'lib/report_builder/prisma_report.rb', line 72 def output(format) send("output_#{format}".to_sym) end |
#output_svg ⇒ Object
76 77 78 79 |
# File 'lib/report_builder/prisma_report.rb', line 76 def output_svg app.headers 'Content-Type' => "image/svg+xml" create_svg end |
#output_svg_download ⇒ Object
81 82 83 84 85 |
# File 'lib/report_builder/prisma_report.rb', line 81 def output_svg_download app.headers 'Content-Type' => "image/svg+xml" app.headers 'Content-Disposition' => "attachment; filename=prisma_flow_diagram_#{@sr[:id]}.svg" create_svg end |
#process_information ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/report_builder/prisma_report.rb', line 39 def process_information @sources_identification=sr.searches_dataset.inject({}) {|ac,v| source=v[:source] ac[source]||=0 ac[source]+=v.records_n ac } @n_rec_database=@sources_identification["database_search"].to_i # records identified on databases @n_rec_back_snow=sr.cd_id_by_stage("screening_references").length # records obtained by snowballing @n_rec_other=@sources_identification.inject(0) {|ac,v| ac+v[1]} - @n_rec_database+ @n_rec_back_snow @n_rec_non_duplicated=sr.cd_id_by_stage("screening_references").length + sr.cd_id_by_stage("screening_title_abstract").length @n_rec_screened=@ars.cd_screened_id("screening_references").count+@ars.cd_screened_id("screening_title_abstract").count @n_rec_rej_screen=@ars.cd_rejected_id("screening_references").count+@ars.cd_rejected_id("screening_title_abstract").count @n_rec_full_assed=sr.cd_id_by_stage("review_full_text").count @n_rec_full_rej=@ars.cd_rejected_id("review_full_text").count @n_rec_full_ace=@ars.cd_accepted_id("review_full_text").count # We need to recover the tag for exclusions # reason_to_exclude=@ars.cd_rejected_id("review_full_text").map {|v| TagBuilder.tag_in_cd(@sr, CanonicalDocument[v]).find_all { |vv| vv.text=~/^ex:/ and vv.mostrar }.map {|vv| vv.text.gsub(/^ex:/,'')}.join("; ") } @reason_to_exclude_count=reason_to_exclude.inject({}) {|ac,v| ac[v]||=0 ac[v]+=1 ac } @svg_reasons=@reason_to_exclude_count.map {|v| "<tspan x='620' dy='1.2em' >#{v[0]} (n = #{v[1]} )</tspan>"}.join("\n") end |