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

[Gokulnath P/Sowmya M] | ADD | Covid report for patients with co-morbidities #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions openmrs/apps/reports/reports.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
{
"patientWithComorbidities": {
"name": "Patient With Co-morbidities",
"type": "MRSGeneric",
"requiredPrivilege": "app:reports",
"config": {
"sqlPath": "/var/www/bahmni_config/openmrs/apps/reports/sql/patientWithComorbiditiesReport.sql"
}
},
"visitReport10": {
"name": "Visit Report",
"type": "visits",
Expand Down
23 changes: 23 additions & 0 deletions openmrs/apps/reports/sql/patientWithComorbiditiesReport.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
SELECT pp.patient_id as "Patient ID",CONCAT(pn.given_name," ",pn.family_name) as "Patient Name",ROUND(DATEDIFF(CURDATE(), p2.birthdate)/365.25, 0 ) as "Age" , p2.gender as "Gender", phn.value as "Phone Number", co.name as "CoMorbidities"
FROM patient_program pp
JOIN program p ON pp.program_id = p.program_id AND p.name = "COVID-19 Program"
JOIN patient_program_attribute ppa ON ppa.patient_program_id = pp.patient_program_id
JOIN program_attribute_type pat ON pat.program_attribute_type_id = ppa.attribute_type_id AND ppa.value_reference="true"
JOIN person p2 ON pp.patient_id = p2.person_id
JOIN person_name pn ON p2.person_id =pn.person_id
LEFT JOIN (
SELECT pa.value, pa.person_id
FROM person_attribute pa
JOIN person_attribute_type pat ON pa.person_attribute_type_id = pat.person_attribute_type_id
WHERE pat.name = "secondaryContact"
) phn ON phn.person_id = pp.patient_id
JOIN (
SELECT DISTINCT o.person_id , cn.name
FROM obs o
JOIN concept_name cn
ON o.value_coded = cn.concept_id and cn.concept_name_type = "FULLY_SPECIFIED"
WHERE o.concept_id = (
SELECT concept_id from concept_name where name = "COVID-19-Starter, Comorbidities"
)
) co ON co.person_id=pn.person_id
where pp.patient_id NOT IN (SELECT DISTINCT person_id FROM obs where concept_id = (SELECT concept_id FROM concept_name where name="COVID-19-Starter, Dose-1"));