Remove test files from repository

This commit is contained in:
2026-07-29 11:41:13 +05:30
parent a01a4c5d82
commit 65875a14c0
12 changed files with 0 additions and 442 deletions
-41
View File
@@ -1,41 +0,0 @@
async function testAPI() {
console.log("1. Requesting Token for jayam_web_ai...");
const tokenResponse = await fetch("http://localhost:8080/v1/auth/token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
grant_type: "client_credentials",
client_id: "jayam_web_ai",
client_secret: "my_secret_key"
})
});
const tokenData = await tokenResponse.json();
if (!tokenData.access_token) {
console.error("Failed to get token!", tokenData);
return;
}
console.log("✅ Successfully received real JWT token!");
console.log("Token:", tokenData.access_token.substring(0, 30) + "...\n");
console.log("2. Using Token to search for drugs (Catalogue API)...");
const searchResponse = await fetch("http://localhost:8080/v1/drugs/search?q=Losartan", {
method: "GET",
headers: {
"Authorization": `Bearer ${tokenData.access_token}`,
"X-Actor-Id": "usr_ph_1234"
}
});
const searchData = await searchResponse.json();
console.log(`✅ API Response Status: ${searchResponse.status}`);
console.log("Drug Search Results:");
console.log(JSON.stringify(searchData, null, 2));
}
testAPI();
-12
View File
@@ -1,12 +0,0 @@
const { Pool } = require('pg');
const pool = new Pool({ connectionString: 'postgres://postgres:csh%402018@localhost:5432/ai_pharmacy' });
pool.query("SELECT id, status, extracted_data FROM prescriptions ORDER BY created_at DESC LIMIT 2")
.then(res => {
console.log(res.rows);
pool.end();
})
.catch(err => {
console.error(err);
pool.end();
});
-16
View File
@@ -1,16 +0,0 @@
const { Pool } = require('pg');
const pool = new Pool({ connectionString: 'postgres://postgres:csh%402018@localhost:5432/ai_pharmacy' });
pool.query("SELECT * FROM dispensing_records ORDER BY created_at DESC LIMIT 5")
.then(res => {
console.log('dispensing_records:', res.rows);
return pool.query("SELECT * FROM stock_movements ORDER BY created_at DESC LIMIT 5");
})
.then(res => {
console.log('stock_movements:', res.rows);
pool.end();
})
.catch(err => {
console.error(err);
pool.end();
});
-12
View File
@@ -1,12 +0,0 @@
const { Pool } = require('pg');
const pool = new Pool({ connectionString: 'postgres://postgres:csh%402018@localhost:5432/ai_pharmacy' });
pool.query("SELECT id, brand_name FROM products")
.then(res => {
console.log('products:', res.rows);
pool.end();
})
.catch(err => {
console.error(err);
pool.end();
});
-57
View File
@@ -1,57 +0,0 @@
async function testDispense() {
console.log("1. Logging in as jayam_web_ai...");
const tokenResponse = await fetch("http://localhost:8080/v1/auth/token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
grant_type: "client_credentials",
client_id: "jayam_web_ai",
client_secret: "my_secret_key"
})
});
const token = (await tokenResponse.json()).access_token;
console.log("\n2. Running Precheck for a pregnant patient...");
const precheckResponse = await fetch("http://localhost:8080/v1/orders/ord_123/precheck", {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"X-Actor-Id": "usr_ph_1234",
"Content-Type": "application/json"
},
body: JSON.stringify({
clinical_context: {
pregnancy: { status: "pregnant" }
},
items: [
{ product_id: "prd_4410", qty: 30 } // Losar 50
]
})
});
console.log("Precheck Results:", JSON.stringify(await precheckResponse.json(), null, 2));
console.log("\n3. Executing Dispense transaction (requesting 30 units of Losar 50)...");
const dispenseResponse = await fetch("http://localhost:8080/v1/orders/ord_123/dispense", {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"X-Actor-Id": "usr_ph_1234",
"Idempotency-Key": "random-uuid-here-" + Date.now(),
"Content-Type": "application/json"
},
body: JSON.stringify({
subject_ref: "pat_123",
items: [
{ product_id: "prd_4410", qty: 30 }
]
})
});
console.log("Dispense Status:", dispenseResponse.status);
console.log("Dispense Results:", JSON.stringify(await dispenseResponse.json(), null, 2));
}
testDispense();
-19
View File
@@ -1,19 +0,0 @@
require('dotenv').config();
const { GoogleGenAI } = require('@google/genai');
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
ai.models.generateContent({
model: 'gemini-3.6-flash',
contents: [
'Hello',
{
inlineData: {
data: Buffer.from('hello').toString("base64"),
mimeType: 'text/plain'
}
}
],
}).then(res => {
console.log('Success:', res.text);
}).catch(err => {
console.error('Error:', err);
});
-60
View File
@@ -1,60 +0,0 @@
import { pool } from './src/db/pool';
async function testGRN() {
console.log("1. Requesting Token...");
const tokenResponse = await fetch("http://localhost:8080/v1/auth/token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
grant_type: "client_credentials",
client_id: "jayam_web_ai",
client_secret: "my_secret_key"
})
});
const tokenData = await tokenResponse.json();
const token = tokenData.access_token;
if (!token) {
console.error("No token received", tokenData);
return;
}
const batchNo = "BAT-" + Date.now();
console.log(`2. Sending GRN for Losar 50 (prd_4410), Batch: ${batchNo}...`);
const grnResponse = await fetch("http://localhost:8080/v1/inventory/grn", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`,
"X-Actor-Id": "usr_ph_admin",
"idempotency-key": "idemp-" + Date.now()
},
body: JSON.stringify({
lines: [
{
batch_no: batchNo,
product_id: "prd_4410",
expiry: "2027-12-31",
qty: 500,
purchase_price: "50.00"
}
]
})
});
const grnData = await grnResponse.json();
console.log("GRN Response Status:", grnResponse.status);
console.log("GRN Response Data:", grnData);
console.log("\n3. Verifying Database...");
const batchRes = await pool.query("SELECT * FROM batches WHERE batch_no = $1", [batchNo]);
console.log("Batch in DB:", batchRes.rows);
const stockMoveRes = await pool.query("SELECT * FROM stock_movements WHERE batch_no = $1", [batchNo]);
console.log("Stock Movements in DB:", stockMoveRes.rows);
process.exit(0);
}
testGRN();
-29
View File
@@ -1,29 +0,0 @@
const http = require('http');
const options = {
hostname: 'localhost',
port: 8080,
path: '/v1/orders/history',
method: 'GET',
headers: {
'Authorization': 'Bearer test',
'X-Actor-Id': 'act_admin'
}
};
const req = http.request(options, res => {
console.log(`statusCode: ${res.statusCode}`);
let data = '';
res.on('data', d => {
data += d;
});
res.on('end', () => {
console.log(data);
});
});
req.on('error', error => {
console.error(error);
});
req.end();
-8
View File
@@ -1,8 +0,0 @@
require('dotenv').config();
const { GoogleGenAI } = require('@google/genai');
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
ai.models.list().then(res => {
console.log(res);
}).catch(err => {
console.error('Error:', err);
});
-116
View File
@@ -1,116 +0,0 @@
import fs from 'fs';
import path from 'path';
async function testPhase2() {
console.log("1. Creating dummy image file...");
const dummyFilePath = path.join(__dirname, 'dummy_rx.jpg');
fs.writeFileSync(dummyFilePath, 'dummy image content');
console.log("2. Requesting Token...");
const tokenResponse = await fetch("http://localhost:8080/v1/auth/token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
grant_type: "client_credentials",
client_id: "jayam_web_ai",
client_secret: "my_secret_key"
})
});
const tokenData = await tokenResponse.json();
const token = tokenData.access_token;
if (!token) {
console.error("No token received", tokenData);
return;
}
console.log("3. Uploading Prescription (POST /v1/prescriptions/upload)...");
// Use fetch with FormData to upload file
const formData = new FormData();
const fileBlob = new Blob([fs.readFileSync(dummyFilePath)], { type: 'image/jpeg' });
formData.append('image', fileBlob, 'dummy_rx.jpg');
const uploadResponse = await fetch("http://localhost:8080/v1/prescriptions/upload", {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"X-Actor-Id": "usr_ph_admin"
},
body: formData as any
});
const uploadData = await uploadResponse.json();
console.log("Upload Status:", uploadResponse.status);
console.log("Upload Data:", uploadData);
const rxId = uploadData.id;
if (uploadResponse.status !== 202) {
console.error("Upload failed");
return;
}
console.log("\n4. Polling for Extraction Results (waiting 6 seconds)...");
await new Promise(resolve => setTimeout(resolve, 6000));
const pollResponse = await fetch(`http://localhost:8080/v1/prescriptions/${rxId}`, {
method: "GET",
headers: {
"Authorization": `Bearer ${token}`,
"X-Actor-Id": "usr_ph_admin"
}
});
const pollData = await pollResponse.json();
console.log("Poll Status:", pollResponse.status);
console.log("Image Path (S3 URL):", pollData.image_path);
console.log("Extracted Data:", JSON.stringify(pollData.extracted_data, null, 2));
console.log("\n5. Testing Confirmation - Human Gate 1");
console.log("Attempting to confirm without explicit selection on low-confidence item...");
const badConfirmPayload = {
items: [
{ explicitly_confirmed: true },
{ explicitly_confirmed: false } // Fails Gate 1
]
};
const badConfirmResponse = await fetch(`http://localhost:8080/v1/prescriptions/${rxId}/confirm`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`,
"X-Actor-Id": "usr_ph_admin"
},
body: JSON.stringify(badConfirmPayload)
});
console.log("Bad Confirm Status (Expect 422):", badConfirmResponse.status);
console.log("Bad Confirm Response:", await badConfirmResponse.json());
console.log("\nAttempting to confirm properly...");
const goodConfirmPayload = {
items: [
{ explicitly_confirmed: true },
{ explicitly_confirmed: true, parsed: { brand: "Hydralazine 25mg" } }
]
};
const goodConfirmResponse = await fetch(`http://localhost:8080/v1/prescriptions/${rxId}/confirm`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`,
"X-Actor-Id": "usr_ph_admin"
},
body: JSON.stringify(goodConfirmPayload)
});
console.log("Good Confirm Status (Expect 200):", goodConfirmResponse.status);
console.log("Good Confirm Response:", await goodConfirmResponse.json());
process.exit(0);
}
testPhase2();
-61
View File
@@ -1,61 +0,0 @@
async function testRemaining() {
console.log("1. Logging in as jayam_web_ai...");
const tokenResponse = await fetch("http://localhost:8080/v1/auth/token", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
grant_type: "client_credentials",
client_id: "jayam_web_ai",
client_secret: "my_secret_key"
})
});
const token = (await tokenResponse.json()).access_token;
console.log("\n2. Executing Goods Receipt Note (GRN)...");
const grnResponse = await fetch("http://localhost:8080/v1/inventory/grn", {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"X-Actor-Id": "usr_mgr_1234",
"Idempotency-Key": "grn-uuid-" + Date.now(),
"Content-Type": "application/json"
},
body: JSON.stringify({
supplier_id: "sup_120",
invoice_no: "INV/2026/9999",
invoice_date: "2026-07-24",
po_ref: "po_8891",
lines: [
{
product_id: "prd_4410",
batch_no: "B9999-" + Date.now(),
expiry: "2028-12-31",
qty: 500,
purchase_price: 54.20,
mrp: 78.50
}
]
})
});
console.log("GRN Status:", grnResponse.status);
console.log("GRN Results:", JSON.stringify(await grnResponse.json(), null, 2));
console.log("\n3. Fetching Audit Logs...");
const auditResponse = await fetch("http://localhost:8080/v1/audit/logs", {
method: "GET",
headers: {
"Authorization": `Bearer ${token}`,
"X-Actor-Id": "usr_mgr_1234"
}
});
console.log("Audit Status:", auditResponse.status);
const auditData = await auditResponse.json();
console.log("Found Stock Movements:", auditData.stock_movements.length);
console.log("Latest Stock Movement:", JSON.stringify(auditData.stock_movements[0], null, 2));
}
testRemaining();
-11
View File
@@ -1,11 +0,0 @@
import { AIService } from './src/modules/ai/service';
import * as dotenv from 'dotenv';
dotenv.config();
const s = new AIService();
s.processVoiceCommand('low stock').then(res => {
console.log("SUCCESS:", res);
process.exit(0);
}).catch(err => {
console.error("FAIL:", err);
process.exit(1);
});