function lab_results_messages($set_pid, $rid, $provider_id = "") { if ($provider_id != "") { $where = "AND id = '" . $provider_id . "'"; } // Get all active users. $rez = sqlStatement("select id, username from users where username != '' AND active = '1' {$where}"); for ($iter = 0; $row = sqlFetchArray($rez); $iter++) { $result[$iter] = $row; } if (!empty($result)) { foreach ($result as $user_detail) { unset($thisauth); // Make sure it is empty. // Check user authorization. Only send the panding review message to authorised user. // $thisauth = acl_check('patients', 'sign', $user_detail['username']); // Route message to administrators if there is no provider match. if ($provider_id == "") { $thisauth = acl_check('admin', 'super', $user_detail['username']); } else { $thisauth = true; } if ($thisauth) { // Send lab result message to the ordering provider when there is a new lab report. $userauthorized = formData("userauthorized"); $pname = getPatientName($set_pid); $link = "<a href='../../orders/orders_results.php?review=1&set_pid={$set_pid}'" . " onclick='return top.restoreSession()'>here</a>"; $note = "Patient {$pname}'s lab results have arrived. Please click {$link} to review them.<br/>"; $note_type = "Lab Results"; $message_status = "New"; // Add pnote. $noteid = addPnote($set_pid, $note, $userauthorized, '1', $note_type, $user_detail['username']); sqlQ("update pnotes set message_status='" . $message_status . "' where id = '{$noteid}'"); } } } }
if ($tmp2) { die("\"{$cmd}\" returned {$tmp2}: {$tmp0}"); } } // If we are posting a patient note... if ($_POST['form_cb_note'] && !$info_msg) { $note = "New scanned encounter note for visit on " . substr($erow['date'], 0, 10); $form_note_message = trim($_POST['form_note_message']); if (get_magic_quotes_gpc()) { $form_note_message = stripslashes($form_note_message); } if ($form_note_message) { $note .= "\n" . $form_note_message; } // addPnote() will do its own addslashes(). addPnote($patient_id, $note, $userauthorized, '1', $_POST['form_note_type'], $_POST['form_note_to']); } // end post patient note } $action_taken = true; } // end copy to chart if ($_POST['form_cb_forward']) { $form_from = trim($_POST['form_from']); $form_to = trim($_POST['form_to']); $form_fax = trim($_POST['form_fax']); $form_message = trim($_POST['form_message']); $form_finemode = $_POST['form_finemode'] ? '-m' : '-l'; if (get_magic_quotes_gpc()) { $form_from = stripslashes($form_from); $form_to = stripslashes($form_to);
$newlname = "~~~MERGED~~~" . $orow['lname']; $sqlstmt = "update patient_data set lname='" . $newlname . "' where pid='" . $otherPID . "'"; if ($commitchanges == true) { $qResults = sqlQ($sqlstmt); } echo "<li>Altered last name of PID " . $otherPID . " to '" . $newlname . "'</li>"; // add patient notes regarding the merged data $notetext = "All related patient data has been merged into patient record PID# " . $masterPID; echo "<li>Added note about the merge to the PID " . $otherPID . "</li>"; if ($commitchanges == true) { addPnote($otherPID, $notetext); } $notetext = "All related patient data has been merged from patient record PID# " . $otherPID; echo "<li>Added note about the merge to the Master PID " . $masterPID . "</li>"; if ($commitchanges == true) { addPnote($masterPID, $notetext); } // add a log entry regarding the merged data if ($commitchanges == true) { newEvent("data_merge", $_SESSION['authUser'], "Default", 1, "Merged PID " . $otherPID . " data into master PID " . $masterPID); } echo "<li>Added entry to log</li>"; echo "<br><br>"; } // end of otherID loop function UpdateTable($tablename, $pid_col, $oldvalue, $newvalue) { global $commitchanges, $oemrdb; $sqlstmt = "select count(*) as numrows from " . $tablename . " where " . $pid_col . "='" . $oldvalue . "'"; $qResults = sqlQ($sqlstmt); if ($qResults) {
/** * Post a patient note that is linked to this document. * * @param string $provider Login name of the provider to receive this note. * @param integer $category_id The desired document category ID * @param string $message Any desired message text for the note. */ function postPatientNote($provider, $category_id, $message = '') { // Build note text in a way that identifies the new document. // See pnotes_full.php which uses this to auto-display the document. $note = $this->get_url_file(); for ($tmp = $category_id; $tmp;) { $catrow = sqlQuery("SELECT name, parent FROM categories WHERE id = ?", array($tmp)); $note = $catrow['name'] . "/{$note}"; $tmp = $catrow['parent']; } $note = "New scanned document " . $this->get_id() . ": {$note}"; if ($message) { $note .= "\n" . $message; } $noteid = addPnote($this->get_foreign_id(), $note, 0, '1', 'New Document', $provider); // Link the new note to the document. setGpRelation(1, $this->get_id(), 6, $noteid); }
if ($noteid && $assigned_to == '-patient-') { // When $assigned_to == '-patient-' we don't update the current note, but // instead create a new one with the current note's body prepended and // attributed to the patient. This seems to be all for the patient portal. $row = getPnoteById($noteid); if (!$row) { die("getPnoteById() did not find id '" . text($noteid) . "'"); } $pres = sqlQuery("SELECT lname, fname " . "FROM patient_data WHERE pid = ?", array($reply_to)); $patientname = $pres['lname'] . ", " . $pres['fname']; $note .= "\n\n{$patientname} on " . $row['date'] . " wrote:\n\n"; $note .= $row['body']; } // There's no note ID, and/or it's assigned to the patient. // In these cases a new note is created. addPnote($reply_to, $note, $userauthorized, '1', $form_note_type, $assigned_to, '', $form_message_status); } } break; case "savePatient": case "save": // Update alert. $noteid = $_POST['noteid']; $form_message_status = $_POST['form_message_status']; $reply_to = $_POST['reply_to']; if ($task == "save") { updatePnoteMessageStatus($noteid, $form_message_status); } else { updatePnotePatient($noteid, $reply_to); } $task = "edit";
reappearPnote($id); } else { disappearPnote($id); } if ($docid) { setGpRelation(1, $docid, 6, $id, !empty($_POST["lnk{$id}"])); } } } } elseif ($mode == "new") { $note = $_POST['note']; if ($noteid) { updatePnote($noteid, $note, $_POST['form_note_type'], $_POST['assigned_to']); $noteid = ''; } else { addPnote($pid, $note, $userauthorized, '1', $_POST['form_note_type'], $_POST['assigned_to']); } } elseif ($mode == "delete") { if ($noteid) { deletePnote($noteid); newEvent("delete", $_SESSION['authUser'], $_SESSION['authProvider'], 1, "pnotes: id " . $noteid); } $noteid = ''; } } $title = ''; $assigned_to = $_SESSION['authUser']; if ($noteid) { $prow = getPnoteById($noteid, 'title,assigned_to,body'); $title = $prow['title']; $assigned_to = $prow['assigned_to'];
$token = $_POST['token']; $patientId = $_POST['patientId']; $notes = $_POST['notes']; $title = isset($_POST['title']) ? $_POST['title'] : 'Unassigned'; $authorized = isset($_POST['authorized']) ? $_POST['title'] : '0'; $activity = isset($_POST['activity']) ? $_POST['activity'] : '1'; $assigned_to = isset($_POST['assigned_to']) ? $_POST['assigned_to'] : ''; $datetime = isset($_POST['datetime']) ? $_POST['datetime'] : ''; $message_status = isset($_POST['message_status']) ? $_POST['message_status'] : 'New'; if ($userId = validateToken($token)) { $username = getUsername($userId); $acl_allow = acl_check('patients', 'notes', $username); if ($acl_allow) { $_SESSION['authProvider'] = getAuthGroup($username); $_SESSION['authUser'] = $username; $result = addPnote($patientId, $notes, $authorized, $activity, $title, $assigned_to, $datetime, $message_status, $username); if ($result) { $xml_array['status'] = 0; $xml_array['result'] = $result; $xml_array['reason'] = 'The Patient notes has been added successfully'; } else { $xml_array['status'] = -1; $xml_array['reason'] = 'ERROR: Sorry, there was an error processing your data. Please re-submit the information again.'; } } else { $xml_array['status'] = -2; $xml_array['reason'] = 'You are not Authorized to perform this action'; } } else { $xml_array['status'] = -2; $xml_array['reason'] = 'Invalid Token';
} $eid = 0 + $erow['pc_eid']; $duration = (int) ($erow['pc_duration'] / 60); $form_mins = formData("form_mins_{$eid}") + 0; $form_fitrel = empty($_POST["form_fitrel_{$eid}"]) ? 0 : 1; sqlStatement("DELETE FROM player_event WHERE pid = '{$plid}' AND " . "date = '{$date}' AND pc_eid = '{$eid}'"); if ($form_mins < $duration) { sqlStatement("INSERT INTO player_event SET " . "pid = '{$plid}', " . "date = '{$date}', " . "pc_eid = '{$eid}', " . "minutes = '{$form_mins}', " . "fitness_related = '{$form_fitrel}'"); } } // Add or append to the roster note. if ($form_note !== '') { if ($noteid) { updatePnote($noteid, $form_note, 'Roster', $form_to); } else { addPnote($plid, $form_note, $userauthorized, '1', 'Roster', $form_to, "{$date} 00:00:00"); } } // Close this window and refresh the roster display. echo "<html>\n<body>\n<script language='JavaScript'>\n"; if ($alertmsg) { echo " alert('{$alertmsg}');\n"; } echo " if (!opener.closed && opener.refreshme) opener.refreshme();\n"; echo " window.close();\n"; echo "</script>\n</body>\n</html>\n"; exit; } ?> <html> <head>
$query = "INSERT INTO issue_encounter ( " . "pid, list_id, encounter " . ") VALUES ( " . "'{$thispid}', '{$issue}', '{$thisenc}'" . ")"; sqlStatement($query); } $tmp_title = $ISSUE_TYPES[$text_type][2] . ": {$form_begin} " . substr($_POST['form_title'], 0, 40); // Close this window and redisplay the updated list of issues. // reload_close($info_msg, $issue, $tmp_title); } else { if ($_POST['form_reconcile']) { if ($issue) { $query = "UPDATE lists SET " . "reconcilestatus = '" . $_POST['form_reconcilestatus'] . "', " . "reconcilenote = '" . $_POST['form_reconcilenote'] . "', " . "reconciledate = NOW() " . "WHERE id = '{$issue}'"; sqlStatement($query); } newEvent('patient-medication-reconcile-update', $_SESSION['user'], $_SESSION['authProvider'], 1, $query); if ($GLOBALS['reconcile_in_pnotes']) { addPnote($thispid, "{$_SESSION['user']} has reconciled {$_POST['form_title']} with status '{$_POST['form_reconcilestatus']}' and note '{$_POST['form_reconcilenote']}'", 1, 1, 'Pharmacy'); } reload_close($info_msg, $issue, $tmp_title); } } $irow = array(); if ($issue) { $irow = sqlQuery("SELECT * FROM lists WHERE id = {$issue}"); } else { if ($thistype) { $irow['type'] = $thistype; } } $type_index = 0; if (!empty($irow['type'])) { foreach ($ISSUE_TYPES as $key => $value) {
function image_result_indication($doc_id, $encounter, $image_procedure_id = 0) { $doc_notes = sqlQuery("select note from notes where foreign_id = ?", array($doc_id)); $narration = isset($doc_notes['note']) ? 'With Narration' : 'Without Narration'; if ($encounter != 0) { $ep = sqlQuery("select u.username as assigned_to from form_encounter inner join users u on u.id = provider_id where encounter = ?", array($encounter)); } else { if ($image_procedure_id != 0) { $ep = sqlQuery("select u.username as assigned_to from procedure_order inner join users u on u.id = provider_id where procedure_order_id = ?", array($image_procedure_id)); } else { $ep = array('assigned_to' => $_SESSION['authUser']); } } $encounter_provider = isset($ep['assigned_to']) ? $ep['assigned_to'] : $_SESSION['authUser']; $noteid = addPnote($_SESSION['pid'], 'New Image Report received ' . $narration, 0, 1, 'Image Results', $encounter_provider, '', 'New', ''); setGpRelation(1, $doc_id, 6, $noteid); }
$message_id = isset($_POST['message_id']) && !empty($_POST['message_id']) ? $_POST['message_id'] : ''; if ($userId = validateToken($token)) { $user = getUsername($userId); $acl_allow = acl_check('patients', 'notes', $user); if ($acl_allow) { $provider_id = $userId; $assigned_to_array = explode(',', $assigned_to); $_SESSION['authUser'] = $user; $_SESSION['authProvider'] = 'Default'; foreach ($assigned_to_array as $assignee) { if ($message_status == 'Done' && !empty($message_id)) { updatePnoteMessageStatus($message_id, $message_status); $result = 1; break; } else { $result = addPnote($patientId, $newtext, $authorized, $activity, $title, $assignee, $datetime = '', $message_status); $device_token_badge = getDeviceTokenBadge($assignee, 'message'); $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 Message Notification!'); } } } if ($result) { $xml_string .= "<status>0</status>"; $xml_string .= "<reason>Message send successfully</reason>"; if ($notification_res) { $xml_string .= "<notification>Notification({$notification_res}) Sent.</notification>"; } else { $xml_string .= "<notification>Notification Failed.</notification>";
case "add": // Add a new message for a specific patient; the message is documented in Patient Notes. // Add a new message; it's treated as a new note in Patient Notes. $note = strip_escape_custom($_POST['note']); $noteid = formData("noteid"); $form_note_type = formData("form_note_type"); $assigned_to = formData("assigned_to"); $form_message_status = formData("form_message_status"); $reply_to = formData("reply_to"); $userauthorized = formData("userauthorized"); if ($noteid) { updatePnote($noteid, $note, $form_note_type, $assigned_to); sqlQuery("update pnotes set message_status='" . $form_message_status . "' where id = '" . $noteid . "'"); $noteid = ''; } else { $noteid = addPnote($reply_to, $note, $userauthorized, '1', $form_note_type, $assigned_to); sqlQuery("update pnotes set message_status='" . $form_message_status . "' where id = '{$noteid}'"); } break; case "save": // Update alert. $noteid = formData("noteid"); $form_message_status = formData("form_message_status"); sqlQuery("update pnotes set message_status='" . $form_message_status . "' where id = '" . $noteid . "'"); $task = "edit"; $note = formData("note"); $title = formData("form_note_type"); $assigned_to = formData("assigned_to"); $reply_to = formData("reply_to"); case "edit": if ($noteid == "") {