if ($acl_allow) { $id = 1; $type = "file_url"; $size = ''; $date = date('Y-m-d H:i:s'); $url = ''; $hash = ''; $image_path = $sitesDir . "{$site}/documents/{$patient_id}"; if (!file_exists($image_path)) { mkdir($image_path); } $image_date = date('YmdHis'); $image_root_path = $image_path . "/" . $image_date . "." . $ext; file_put_contents($image_root_path, $image_content); $res = addNewDocument($image_date . "." . $ext, 'image/png', $image_root_path, 0, filesize($image_root_path), $userId, $patient_id, $cat_id, $higher_level_path = '', $path_depth = '1'); $lab_report_catid = document_category_to_id("Lab Report"); if ($cat_id == $lab_report_catid) { $device_token_badge = getDeviceTokenBadge($provider_username, 'labreport'); $badge = $device_token_badge['badge']; $deviceToken = $device_token_badge['device_token']; if ($deviceToken) { $notification_res = notification($deviceToken, $badge, $msg_count = 0, $apt_count = 0, $message = 'New Labreport Notification!'); } } if ($res) { $xml_array['status'] = "0"; $xml_array['reason'] = "Document added successfully"; if ($notification_res) { $xml_array['notification'] = 'Add Patient document Notification(' . $notification_res . ')'; } else { $xml_array['notification'] = 'Notificaiotn Failed.';
} else { $xml_array['status'] = -1; $xml_array['reason'] = 'ERROR: Sorry, there was an error processing your data. Please re-submit the information again.'; } if ($image_data) { $id = 1; $type = "file_url"; $size = ''; $date = date('Y-m-d H:i:s'); $url = ''; $mimetype = 'image/png'; $hash = ''; $patient_id = $patientId; $ext = 'png'; $cat_title = 'Patient Photograph'; $cat_id = document_category_to_id($cat_title); $image_path = $sitesDir . "{$site}/documents/{$patient_id}"; if (!file_exists($image_path)) { mkdir($image_path); } $image_date = date('YmdHis'); $image_root_path = $image_path . "/" . $image_date . "." . $ext; file_put_contents($image_root_path, base64_decode($image_data)); $res = addNewDocument($image_date . "." . $ext, $mimetype, $image_root_path, 0, filesize($image_root_path), $userId, $patient_id, $cat_id, $higher_level_path = '', $path_depth = '1'); } } else { $xml_array['status'] = -2; $xml_array['reason'] = 'You are not Authorized to perform this action'; } } else { $xml_array['status'] = -2;