Files
AI_Pharmacy_Api/patch_webhook_db.js

19 lines
1.0 KiB
JavaScript

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 target3 = ` // 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();`;
const replace3 = ` // Find patient ID from users table using full name match via DB to bypass any scopes
$patient = \\Illuminate\\Support\\Facades\\DB::table('users')
->whereRaw("LOWER(CONCAT(first_name, ' ', last_name)) = ?", [strtolower(trim($subjectRef))])
->orWhere('id', $subjectRef)
->first();`;
code = code.replace(target3, replace3);
fs.writeFileSync(path, code);
console.log("Successfully patched to use DB::table('users')");