feat: add core backend modules, inventory services, and patch scripts for AI Pharmacy API

This commit is contained in:
2026-09-15 11:15:15 +05:30
parent 22a03043ea
commit 1f9378d96c
41 changed files with 1413 additions and 130 deletions
+21
View File
@@ -0,0 +1,21 @@
const { pool } = require('./src/db/pool');
async function test() {
const query = `
SELECT
p.id as product_id,
p.brand_name,
d.generic_name,
(SELECT COALESCE(SUM(qty_on_hand), 0) FROM batches WHERE product_id = p.id AND expiry > CURRENT_DATE AND tenant_id = $2) as total_stock
FROM products p
JOIN drugs d ON p.drug_id = d.id
WHERE p.tenant_id = $2 OR EXISTS (SELECT 1 FROM batches WHERE product_id = p.id AND tenant_id = $2) OR p.tenant_id IS NULL
ORDER BY p.brand_name ASC
LIMIT $1
`;
const { rows } = await pool.query(query, [50, 'act_admin']);
console.log(rows);
process.exit();
}
test();