feat: add core backend modules, inventory services, and patch scripts for AI Pharmacy API
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { IdentityService } from '../src/modules/identity/service';
|
||||
import { CatalogueService } from '../src/modules/catalogue/service';
|
||||
import { pool } from '../src/db/pool';
|
||||
|
||||
async function testRegister() {
|
||||
const identityService = new IdentityService();
|
||||
const catalogueService = new CatalogueService();
|
||||
|
||||
const hospitalId = 'hosp_test_' + Date.now();
|
||||
const username = 'pharmacist_hosp_' + Date.now();
|
||||
|
||||
console.log(`Registering user ${username} for hospital ${hospitalId}...`);
|
||||
const registered = await identityService.registerUser({
|
||||
hospital_id: hospitalId,
|
||||
username: username,
|
||||
passwordPlain: 'Password@2026',
|
||||
pharmacy_name: 'Test Hospital Pharmacy',
|
||||
address: '123 Hospital St'
|
||||
});
|
||||
|
||||
console.log('Registered User:', registered);
|
||||
|
||||
// Fetch stock catalogue for registered hospital pharmacy tenant
|
||||
const drugs = await catalogueService.getAllDrugs(50, hospitalId);
|
||||
console.log('Drugs returned for tenant:', drugs.length);
|
||||
drugs.forEach((d: any) => {
|
||||
console.log(` - ${d.brand_name} (${d.generic_name}) Total Stock: ${d.total_stock}`);
|
||||
});
|
||||
|
||||
await pool.end();
|
||||
}
|
||||
|
||||
testRegister().catch(console.error);
|
||||
Reference in New Issue
Block a user