Import Patient Document To OpenEMR From Another System

Hi I am new to OpenEMR as well as PHP development. Am looking for help on importing patient document to OpenEMR from another system. Here is my clarifications

(1) What is the purpose Hash column in the Documents table, and how it is generated
(2) How the document was encrypt and stored in OpenEMR

Any help is appreciated, thanks in advance

hi @Prabu_Mohandoss , if you use the document service you don’t have to worry about the details. However you can find them at this location for v6.0.0.

Hi Stephen, thank you very much for your help!, I’m looking into this…

Hi , i have question i want to get the patient image from customised API i did it , any help with how we can put this picture in patient document

thank you

@yaqeen I have writen below code assign document to patient



 * Display, enter, modify and manage patient notes.


 * @package   OpenEMR

 * @link

 * @author    Nilesh Hake <>

 * @copyright Copyright (c) 2024 Nilesh <>

 * @license GNU General Public License 3



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);
1 Like

thank you @Nilesh_Hake , but where do i put this file ?

@yaqeen wherever your trying load the document into your code.

1 Like