@yaqeen I have writen below code assign document to patient
<?php
/**
* Display, enter, modify and manage patient notes.
*
* @package OpenEMR
* @link http://www.open-emr.org
* @author Nilesh Hake <nbhbiotech.hake@gmail.com>
* @copyright Copyright (c) 2024 Nilesh <nbhbiotech.hake@gmail.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
require_once('../../globals.php');
require_once($GLOBALS['srcdir'] . "/documents.php");
$respone = array();
$respone['status'] =false;
$patient_id = $_POST['patient_id'];
if (!empty($_FILES)) {
$category_id = document_category_to_id("Referral Letters");
$name = $_FILES['file']['name'];
$type = $_FILES['file']['type'];
$tmp_name = $_FILES['file']['tmp_name'];
$size = $_FILES['file']['size'];
$owner = $GLOBALS['userauthorized'];
$error = 0;
$doc_details = addNewDocument($name, $type, $tmp_name, $error, $size, $owner, $patient_id, $category_id);
$respone['status'] =true;
$respone['doc_id'] = $doc_details['doc_id'];
}
echo json_encode($respone);