Exemple #1
0
/**
 * Function to add a document via the C_Document class.
 *
 * @param  string         $name                            Name of the document
 * @param  string         $type                            Mime type of file
 * @param  string         $tmp_name                        Temporary file name
 * @param  string         $error                           Errors in file upload
 * @param  string         $size                            Size of file
 * @param  int            $owner                           Owner/user/service that imported the file
 * @param  string         $patient_id_or_simple_directory  Patient id or simple directory for storage when patient id not known (such as '00' or 'direct')
 * @param  int            $category_id                     Document category id
 * @param  string         $higher_level_path               Can set a higher level path here (and then place the path depth in $path_depth)
 * @param  int            $path_depth                      Path depth when using the $higher_level_path feature
 * @return array/boolean                                   Array(doc_id,url) of the file as stored in documents table, false = failure
 */
function addNewDocument($name, $type, $tmp_name, $error, $size, $owner = '', $patient_id_or_simple_directory = "00", $category_id = '1', $higher_level_path = '', $path_depth = '1')
{
    if (empty($owner)) {
        $owner = $_SESSION['authUserID'];
    }
    // Build the $_FILES array
    $TEMP_FILES = array();
    $TEMP_FILES['file']['name'][0] = $name;
    $TEMP_FILES['file']['type'][0] = $type;
    $TEMP_FILES['file']['tmp_name'][0] = $tmp_name;
    $TEMP_FILES['file']['error'][0] = $error;
    $TEMP_FILES['file']['size'][0] = $size;
    $_FILES = $TEMP_FILES;
    // Build the parameters
    $_GET['higher_level_path'] = $higher_level_path;
    $_GET['patient_id'] = $patient_id_or_simple_directory;
    $_POST['destination'] = '';
    $_POST['submit'] = 'Upload';
    $_POST['path_depth'] = $path_depth;
    $_POST['patient_id'] = is_numeric($patient_id_or_simple_directory) && $patient_id_or_simple_directory > 0 ? $patient_id_or_simple_directory : "00";
    $_POST['category_id'] = $category_id;
    $_POST['process'] = 'true';
    // Add the Document and return the newly added document id
    $cd = new C_Document();
    $cd->manual_set_owner = $owner;
    $cd->upload_action_process();
    $v = $cd->get_template_vars("file");
    if (!isset($v) || !$v) {
        return false;
    }
    return array("doc_id" => $v[0]->id, "url" => $v[0]->url);
}
Exemple #2
0
 /**  
 * To move category,rename filename,input note and to move to new patient#
 */
 public function documents_update($data)
 {
     if ($this->valid($data[0])) {
         $_POST['process'] = true;
         $_POST['new_category_id'] = $data[1];
         $_POST['new_patient_id'] = $data[4];
         $file_path = '';
         if ($data[9] == 2) {
             $file_path = $GLOBALS['OE_SITE_DIR'] . "/documents/myportal/unsigned/" . $data[6];
         } elseif ($data[9] == 1) {
             $file_path = $GLOBALS['OE_SITE_DIR'] . "/documents/myportal/signed/" . $data[6];
         } elseif ($data[9] == 4) {
             $file_path = $GLOBALS['OE_SITE_DIR'] . "/documents/myportal/patientuploads/" . $data[5] . "/" . $data[6];
         }
         $mime_types = array("pdf" => "application/pdf", "exe" => "application/octet-stream", "zip" => "application/zip", "docx" => "application/msword", "doc" => "application/msword", "xls" => "application/vnd.ms-excel", "ppt" => "application/vnd.ms-powerpoint", "gif" => "image/gif", "png" => "image/png", "jpeg" => "image/jpg", "jpg" => "image/jpg", "mp3" => "audio/mpeg", "wav" => "audio/x-wav", "mpeg" => "video/mpeg", "mpg" => "video/mpeg", "mpe" => "video/mpeg", "mov" => "video/quicktime", "avi" => "video/x-msvideo", "3gp" => "video/3gpp", "css" => "text/css", "jsc" => "application/javascript", "js" => "application/javascript", "php" => "text/html", "htm" => "text/html", "html" => "text/html");
         $extension = strtolower(end(explode('.', $file_path)));
         $mime_types = $mime_types[$extension];
         $_FILES['file']['name'][0] = $data[6];
         $_FILES['file']['type'][0] = $mime_types;
         $_FILES['file']['tmp_name'][0] = $file_path;
         $_FILES['file']['error'][0] = 0;
         $_FILES['file']['size'][0] = filesize($file_path);
         $_POST['category_id'] = $_POST['new_category_id'];
         $_POST['patient_id'] = $_POST['new_patient_id'];
         $_GET['patient_id'] = $_POST['patient_id'];
         $_POST['destination'] = $data[3];
         $cdoc = new C_Document();
         $cdoc->upload_action_process();
         if ($GLOBALS['document_storage_method'] == 0) {
             if ($data[3]) {
                 copy($file_path, $cdoc->file_path . $data[3]);
             } else {
                 copy($file_path, $cdoc->file_path . $data[6]);
             }
         }
         $foreign_id = sqlQuery("select id from documents where foreign_id = ? order by id desc limit 1", array($_POST['new_patient_id']));
         unset($_POST);
         $_POST['encrypted'] = '';
         $_POST['passphrase'] = '';
         $_POST['process'] = true;
         $_POST['foreign_id'] = $foreign_id['id'];
         $_POST['note'] = $data[7];
         $cdoc->note_action_process($_GET['patient_id']);
         $sql_patient_no = "UPDATE documents_legal_detail SET dld_moved = '1' WHERE dld_master_docid = ? AND dld_id = ?";
         sqlQuery($sql_patient_no, array($data[2], $data[8]));
         unset($_POST);
     }
 }