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
+29
View File
@@ -0,0 +1,29 @@
const fs = require('fs');
const path = 'C:/Users/CSH12/Desktop/Hospital_Api/all-applications-api/app/Services/PharmacyWebhookController.php';
let code = fs.readFileSync(path, 'utf8');
const target2 = `} elseif ($subjectRef) {
try {
// Try to find the latest prescription for this patient ref
$latestPrescription = \\App\\Entities\\PatientHealth::where('patient_id', $subjectRef)
->whereIn('slug', ['prescription', 'patient-prescription', 'medication-prescription'])
->latest()
->first();`;
const replace2 = `} elseif ($subjectRef) {
try {
// Find patient ID from users table using full name match
$patient = \\App\\Entities\\User::whereRaw("LOWER(CONCAT(first_name, ' ', last_name)) = ?", [strtolower(trim($subjectRef))])
->orWhere('id', $subjectRef)
->first();
$patientIdToSearch = $patient ? $patient->id : $subjectRef;
// Try to find the latest prescription for this patient ID
$latestPrescription = \\App\\Entities\\PatientHealth::where('patient_id', $patientIdToSearch)
->latest()
->first();`;
code = code.replace(target2, replace2);
fs.writeFileSync(path, code);
console.log("Successfully patched PharmacyWebhookController fallback logic");