Skip to content

Commit

Permalink
BAH-4068 | Add. Reports for OpenElis report and Odoo report (#47)
Browse files Browse the repository at this point in the history
* BAH-4068 | Add. Reports for OpenElis report and Odoo report

* BAH-4068 | Fix. Missing empty line issues in reports sql files
  • Loading branch information
mohan-13 authored Aug 12, 2024
1 parent b8a7987 commit bb98167
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
16 changes: 16 additions & 0 deletions openmrs/apps/reports/reports.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,22 @@
"showTotalRow": true,
"showTotalColumn": true
}
},
"OpenELISTestCount": {
"name": "OpenELIS Test Count",
"type": "ElisGeneric",
"requiredPrivilege": "app:reports",
"config": {
"sqlPath": "/etc/bahmni_config/openmrs/apps/reports/sql/testCount.sql"
}
},
"OdooInvoiceSummary": {
"name": "Odoo Invoicing Summary",
"type": "ERPGeneric",
"requiredPrivilege": "app:reports",
"config": {
"sqlPath": "/etc/bahmni_config/openmrs/apps/reports/sql/odooInvoiceSummary.sql"
}
}
}

Expand Down
14 changes: 14 additions & 0 deletions openmrs/apps/reports/sql/odooInvoiceSummary.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SELECT
DATE(invoice_date) AS "Date",
COUNT(id) AS "Number of Invoices",
SUM((amount_total - discount) + round_off_amount) AS "Total Invoice Value"
FROM
account_move
WHERE
move_type = 'out_invoice'
AND state = 'posted'
AND DATE(invoice_date) BETWEEN '#startDate#' AND '#endDate#'
GROUP BY
DATE(invoice_date)
ORDER BY
invoice_date ASC;
20 changes: 6 additions & 14 deletions openmrs/apps/reports/sql/testCount.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
SELECT DISTINCT
ts.name AS DDepartment,
t.name AS test,
count(r.id) AS total_count,
CASE WHEN t.id IN (SELECT test_id FROM test_result WHERE tst_rslt_type = 'D') THEN count(r1.id) ELSE NULL END AS positive,
CASE WHEN t.id IN (SELECT test_id FROM test_result WHERE tst_rslt_type = 'D') THEN count(r2.id) ELSE NULL END AS negative
FROM test_section ts
INNER JOIN test t ON ts.id = t.test_section_id AND t.is_active = 'Y'
LEFT OUTER JOIN analysis a ON t.id = a.test_id
LEFT OUTER JOIN result r ON a.id = r.analysis_id and cast(r.lastupdated as date) BETWEEN '#startDate#' and '#endDate#' and r.value != ''
LEFT OUTER JOIN result r1 ON r1.result_type = 'D' and r1.value != '' and r.id=r1.id and r1.abnormal=false
LEFT OUTER JOIN result r2 on r2.result_type = 'D' and r2.value != '' and r.id=r2.id and r2.abnormal=true
GROUP BY ts.name, t.name, t.id
order by ts.name;
SELECT DATE(lastupdated) AS "Date",
COUNT(id) AS "Number of Test Results Captured"
FROM result
WHERE DATE(lastupdated) BETWEEN '#startDate#' AND '#endDate#'
GROUP BY DATE(lastupdated)
ORDER BY DATE(lastupdated) ASC;

0 comments on commit bb98167

Please sign in to comment.