=== 2026-01-06 08:27:26 ===
Input: {"hospital_id":1,"patient_id":208,"token_number":"1"}
Hospital ID: 1
Patient ID: 208
Token Number: '1'
Check patient SQL: SELECT * FROM patients WHERE id = 208 AND hospital_id = 1
Patient NOT found in patients table with id=208 and hospital_id=1
Check prescription SQL: SELECT COUNT(*) as count FROM prescriptions p WHERE p.hospital_id = 1 AND p.patient_id = 208
Prescription count: 1
Main SQL Query: SELECT 
                    p.*,
                    pt.name as patient_name,
                    pt.mobile as patient_mobile,
                    pt.age as patient_age,
                    pt.gender as patient_gender,
                    pt.blood_group,
                    d.name as doctor_name,
                    d.specialization as doctor_specialization
                FROM prescriptions p
                LEFT JOIN patients pt ON p.patient_id = pt.id AND pt.hospital_id = p.hospital_id
                LEFT JOIN doctors d ON p.doctor_id = d.id
                WHERE p.hospital_id = 1 AND p.patient_id = 208
                ORDER BY p.prescribed_date DESC, p.id DESC
                LIMIT 1
Query failed: Unknown column 'pt.name' in 'field list'
Response: Array
(
    [success] => 
    [data] => 
    [message] => Query failed: Unknown column 'pt.name' in 'field list'
    [debug] => Array
        (
            [received] => Array
                (
                    [hospital_id] => 1
                    [patient_id] => 208
                    [token_number] => 1
                )

        )

)

=== END ===

=== 2026-01-06 08:28:04 ===
Input: {"hospital_id":1,"patient_id":208,"token_number":"1"}
Hospital ID: 1
Patient ID: 208
Token Number: '1'
Check patient SQL: SELECT * FROM patients WHERE id = 208 AND hospital_id = 1
Patient NOT found in patients table with id=208 and hospital_id=1
Check prescription SQL: SELECT COUNT(*) as count FROM prescriptions p WHERE p.hospital_id = 1 AND p.patient_id = 208
Prescription count: 1
Main SQL Query: SELECT 
                    p.*,
                   
                  
                  
                   
                    d.name as doctor_name,
                    d.specialization as doctor_specialization
                FROM prescriptions p
                LEFT JOIN patients pt ON p.patient_id = pt.id AND pt.hospital_id = p.hospital_id
                LEFT JOIN doctors d ON p.doctor_id = d.id
                WHERE p.hospital_id = 1 AND p.patient_id = 208
                ORDER BY p.prescribed_date DESC, p.id DESC
                LIMIT 1
Query failed: Unknown column 'pt.id' in 'on clause'
Response: Array
(
    [success] => 
    [data] => 
    [message] => Query failed: Unknown column 'pt.id' in 'on clause'
    [debug] => Array
        (
            [received] => Array
                (
                    [hospital_id] => 1
                    [patient_id] => 208
                    [token_number] => 1
                )

        )

)

=== END ===

