34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
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);
|