diff --git a/openmrs/apps/reports/reports.json b/openmrs/apps/reports/reports.json index 8a8e72522..a47056dca 100644 --- a/openmrs/apps/reports/reports.json +++ b/openmrs/apps/reports/reports.json @@ -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" + } } } diff --git a/openmrs/apps/reports/sql/odooInvoiceSummary.sql b/openmrs/apps/reports/sql/odooInvoiceSummary.sql new file mode 100644 index 000000000..fd95a38ee --- /dev/null +++ b/openmrs/apps/reports/sql/odooInvoiceSummary.sql @@ -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; diff --git a/openmrs/apps/reports/sql/testCount.sql b/openmrs/apps/reports/sql/testCount.sql index 7ca34b860..a5e9daa98 100644 --- a/openmrs/apps/reports/sql/testCount.sql +++ b/openmrs/apps/reports/sql/testCount.sql @@ -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; \ No newline at end of file +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;