<?php
include 'functions.php';

if (isset($_GET['id'])) {
    $documentId = $_GET['id'];
    $query = "SELECT pmed_file_path, pmed_file_name FROM pmed_documents WHERE pmed_document_id = '$documentId'";
    $result = $conn->query($query);
    
    if ($result->num_rows > 0) {
        $row = $result->fetch_assoc();
        echo json_encode([
            'filePath' => $row['pmed_file_path'],
            'originalFileName' => $row['pmed_file_name']
        ]);
    } else {
        echo json_encode(['error' => 'File not found']);
    }
}
?>