Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional reports #1049

Merged
merged 2 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions server/app/reports/diseases_with_icdo.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require 'set'

class DiseasesWithIcdo < Report
attr_reader :qualifying_disease_ids

def self.name
"Counts of Diseases and EIDs with and without DO and ICD-O terms"
end

def self.description
"Generate counts of Evidence Items and Diseases that have associated DOIDs and ICD-O terms"
end

def setup
@qualifying_disease_ids = Set.new
candidate_diseases = Disease.joins(:evidence_items)
.where.not(evidence_items: {status: 'rejected'})
.where.not(doid: nil).distinct

candidate_diseases.find_each do |disease|
resp = MyDiseaseInfo.new(disease).response
if resp && resp[:icdo].present?
@qualifying_disease_ids << disease.id
end
sleep 0.1
end


end

def headers
[
"Total Diseases",
"Total Diseases Associated with a DOID and ICD-O code",
"Total Non Rejected EIDs",
"Total Non Rejected EIDs Associated with a DOID and ICD-O code.",
]
end

def execute
data << [
Disease.joins(:evidence_items).where.not(evidence_items: {status: 'rejected'}).distinct.count,
qualifying_disease_ids.size,
EvidenceItem.where.not(status: 'rejected').count,
EvidenceItem.where.not(status: 'rejected').where(disease_id: qualifying_disease_ids).count,
]
end
end
41 changes: 41 additions & 0 deletions server/app/reports/eids_with_onset_terms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class EidsWithOnsetTerms < Report
attr_reader :onset_terms

def self.name
"EIDs with Onset Terms"
end

def self.description
"Generate a list of EIDs with any of the following onset terms: Young adult, early young adult, intermediate young adult, late young adult, childhood, juvenile, pediatric, congenital, and infantile."
end

def setup
@onset_terms = Phenotype.where(hpo_class: [
'Young adult onset',
'Intermediate young adult onset',
'Late young adult onset',
'Childhood onset',
'Juvenile onset',
'Pediatric onset',
'Congenital onset',
'Infantile onset'
])
end

def headers
[
"EID",
"Link",
"HPO Term",
"HPO ID"
]
end

def execute
onset_terms.each do |term|
term.evidence_items.each do |eid|
data << ["EID#{eid.id}", "https://civicdb.org/#{eid.link}", term.hpo_class, term.hpo_id]
end
end
end
end
4 changes: 3 additions & 1 deletion server/app/reports/reports.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Reports
AVAILABLE_REPORTS = [
OrganizationContributions
OrganizationContributions,
EidsWithOnsetTerms,
DiseasesWithIcdo
]
end
Loading