Ejemplo n.º 1
1
function image_widget($doc_id, $doc_catg)
{
    global $pid, $web_root;
    $docobj = new Document($doc_id);
    $image_file = $docobj->get_url_file();
    $extension = substr($image_file, strrpos($image_file, "."));
    $viewable_types = array('.png', '.jpg', '.jpeg', '.png', '.bmp');
    // image ext supported by fancybox viewer
    if (in_array($extention, $viewable_types) == 0) {
        // extention matches list
        $to_url = "<a href = {$web_root}" . "/controller.php?document&retrieve&patient_id={$pid}&document_id={$doc_id}" . "/tmp.{$extension}" . " onclick=top.restoreSession(); class='image_modal'>" . " <img src = {$web_root}" . "/controller.php?document&retrieve&patient_id={$pid}&document_id={$doc_id}" . " width=100 alt='{$doc_catg}:{$image_file}' align='center'>" . htmlspecialchars(" {$doc_catg}: {$image_file}") . " </a> <br /><br />";
    } else {
        $to_url = "<a href='" . $web_root . "/controller.php?document&retrieve" . "&patient_id={$pid}&document_id={$doc_id}'" . " onclick='top.restoreSession()' class='css_button_small'>" . "<span>" . htmlspecialchars(xl("View"), ENT_QUOTES) . "</a> &nbsp;" . htmlspecialchars("{$doc_catg} - {$image_file}", ENT_QUOTES) . "</span> <br /><br />";
    }
    echo $to_url;
}
Ejemplo n.º 2
0
    } else {
        ?>
<a href="pnotes_full.php?<?php 
        echo $urlparms;
        ?>
" target="Main" onclick="top.restoreSession()">
<?php 
    }
    ?>

<span class="title"><?php 
    echo htmlspecialchars(xl('Notes'), ENT_NOQUOTES);
    if ($docid) {
        echo " " . xlt("linked to document") . " ";
        $d = new Document($docid);
        echo $d->get_url_file();
    } else {
        if ($orderid) {
            echo " " . xlt("linked to procedure order") . " {$orderid}";
        }
    }
    ?>
</span>
<span class=more><?php 
    echo htmlspecialchars($tmore, ENT_NOQUOTES);
    ?>
</span>
</a>
<?php 
}
?>
Ejemplo n.º 3
0
echo htmlspecialchars($docid, ENT_QUOTES);
?>
&orderid=<?php 
echo htmlspecialchars($orderid, ENT_QUOTES);
?>
&<?php 
echo attr($activity_string_html);
?>
' onsubmit='return top.restoreSession()'>

<?php 
$title_docname = "";
if ($docid) {
    $title_docname .= " " . xl("linked to document") . " ";
    $d = new Document($docid);
    $title_docname .= $d->get_url_file();
}
if ($orderid) {
    $title_docname .= " " . xl("linked to procedure order") . " {$orderid}";
}
$urlparms = "docid={$docid}&orderid={$orderid}";
?>

    <div>
        <span class="title"><?php 
echo xlt('Patient Notes') . $title_docname;
?>
</span>
    </div>
    <div id='namecontainer_pnotes' class='namecontainer_pnotes' style='float:left;margin-right:10px'>
        <?php 
Ejemplo n.º 4
0
 function update_action_process($patient_id = "", $document_id)
 {
     if ($_POST['process'] != "true") {
         die("process is '" . $_POST['process'] . "', expected 'true'");
         return;
     }
     $docdate = $_POST['docdate'];
     $docname = $_POST['docname'];
     $issue_id = $_POST['issue_id'];
     if (is_numeric($document_id)) {
         $messages = '';
         $d = new Document($document_id);
         $file_name = $d->get_url_file();
         if ($docname != '' && $docname != $file_name) {
             $path = $d->get_url_filepath();
             $path = str_replace($file_name, "", $path);
             $new_url = $this->_rename_file($path . $docname);
             if (rename($d->get_url(), $new_url)) {
                 // check the "converted" file, and delete it if it exists. It will be regenerated when report is run
                 $url = preg_replace("|^(.*)://|", "", $d->get_url());
                 $convertedFile = substr(basename($url), 0, strrpos(basename($url), '.')) . '_converted.jpg';
                 $url = $GLOBALS['OE_SITE_DIR'] . '/documents/' . $patient_id . '/' . $convertedFile;
                 if (file_exists($url)) {
                     unlink($url);
                 }
                 $d->url = $new_url;
                 $d->persist();
                 $d->populate();
                 $messages .= xl('Document successfully renamed.') . "<br>";
             } else {
                 $messages .= xl('The file could not be succesfully renamed, this error is usually related to permissions problems on the storage system.') . "<br>";
             }
         }
         if (preg_match('/^\\d\\d\\d\\d-\\d+-\\d+$/', $docdate)) {
             $docdate = "'{$docdate}'";
         } else {
             $docdate = "NULL";
         }
         if (!is_numeric($issue_id)) {
             $issue_id = 0;
         }
         $sql = "UPDATE documents SET docdate = {$docdate}, " . "list_id = '{$issue_id}' " . "WHERE id = '{$document_id}'";
         $this->tree->_db->Execute($sql);
         $messages .= xl('Document date and issue updated successfully') . "<br>";
     }
     $this->_state = false;
     $this->assign("messages", $messages);
     return $this->view_action($patient_id, $document_id);
 }
Ejemplo n.º 5
0
 function tag_action_process($patient_id = "", $document_id)
 {
     if ($_POST['process'] != "true") {
         die("process is '" . text($_POST['process']) . "', expected 'true'");
         return;
     }
     // Create Encounter and Tag it.
     $event_date = date('Y-m-d H:i:s');
     $encounter_id = $_POST['encounter_id'];
     $encounter_check = $_POST['encounter_check'];
     $visit_category_id = $_POST['visit_category_id'];
     if (is_numeric($document_id)) {
         $messages = '';
         $d = new Document($document_id);
         $file_name = $d->get_url_file();
         if (!is_numeric($encounter_id)) {
             $encounter_id = 0;
         }
         $encounter_check = $encounter_check == 'on' ? 1 : 0;
         if ($encounter_check) {
             $provider_id = $_SESSION['authUserID'];
             // Get the logged in user's facility
             $facilityRow = sqlQuery("SELECT username, facility, facility_id FROM users WHERE id = ?", array("{$provider_id}"));
             $username = $facilityRow['username'];
             $facility = $facilityRow['facility'];
             $facility_id = $facilityRow['facility_id'];
             // Get the primary Business Entity facility to set as billing facility, if null take user's facility as billing facility
             $billingFacility = sqlQuery("SELECT id FROM facility WHERE primary_business_entity = 1");
             $billingFacilityID = $billingFacility['id'] ? $billingFacility['id'] : $facility_id;
             $conn = $GLOBALS['adodb']['db'];
             $encounter = $conn->GenID("sequences");
             $query = "INSERT INTO form_encounter SET\n\t\t\t\t\t\tdate = ?,\n\t\t\t\t\t\treason = ?,\n\t\t\t\t\t\tfacility = ?,\n\t\t\t\t\t\tsensitivity = 'normal', \n\t\t\t\t\t\tpc_catid = ?,\n\t\t\t\t\t\tfacility_id = ?,\n\t\t\t\t\t\tbilling_facility = ?,\n\t\t\t\t\t\tprovider_id = ?,\n\t\t\t\t\t\tpid = ?,\n\t\t\t\t\t\tencounter = ?";
             $bindArray = array($event_date, $file_name, $facility, $_POST['visit_category_id'], (int) $facility_id, (int) $billingFacilityID, (int) $provider_id, $patient_id, $encounter);
             $formID = sqlInsert($query, $bindArray);
             addForm($encounter, "New Patient Encounter", $formID, "newpatient", $patient_id, "1", date("Y-m-d H:i:s"), $username);
             $d->set_encounter_id($encounter);
         } else {
             $d->set_encounter_id($encounter_id);
         }
         $d->set_encounter_check($encounter_check);
         $d->persist();
         $messages .= xlt('Document tagged to Encounter successfully') . "<br>";
     }
     $this->_state = false;
     $this->assign("messages", $messages);
     return $this->view_action($patient_id, $document_id);
 }
Ejemplo n.º 6
0
<?php 
    if ($noteid) {
        // Get the related document IDs if any.
        $tmp = sqlStatement("SELECT id1 FROM gprelations WHERE " . "type1 = ? AND type2 = ? AND id2 = ?", array('1', '6', $noteid));
        if (sqlNumRows($tmp)) {
            echo " <tr>\n";
            echo "  <td class='text'><b>";
            echo xlt('Linked document') . ":</b>\n";
            while ($gprow = sqlFetchArray($tmp)) {
                $d = new Document($gprow['id1']);
                $enc_list = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe " . " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid  WHERE fe.pid = ? order by fe.date desc", array($prow['pid']));
                $str_dob = htmlspecialchars(xl("DOB") . ":" . $prow['DOB'] . " " . xl("Age") . ":" . getPatientAge($prow['DOB']));
                $pname = $prow['fname'] . " " . $prow['lname'];
                echo "<a href='javascript:void(0);' ";
                echo "onClick=\"gotoReport(" . addslashes(attr($d->get_id())) . ",'" . addslashes(attr($pname)) . "'," . addslashes(attr($prow['pid'])) . "," . addslashes(attr($prow['pubpid'])) . ",'" . addslashes(attr($str_dob)) . "');\">";
                echo text($d->get_url_file());
                echo "</a>\n";
            }
            echo "  </td>\n";
            echo " </tr>\n";
        }
        // Get the related procedure order IDs if any.
        $tmp = sqlStatement("SELECT id1 FROM gprelations WHERE " . "type1 = ? AND type2 = ? AND id2 = ?", array('2', '6', $noteid));
        if (sqlNumRows($tmp)) {
            echo " <tr>\n";
            echo "  <td class='text'><b>";
            echo xlt('Linked procedure order') . ":</b>\n";
            while ($gprow = sqlFetchArray($tmp)) {
                echo "   <a href='";
                echo $GLOBALS['webroot'] . "/interface/orders/single_order_results.php?orderid=";
                echo $gprow['id1'];
Ejemplo n.º 7
0
function image_widget($doc_id, $doc_catg)
{
    global $pid, $web_root;
    $docobj = new Document($doc_id);
    $image_file = $docobj->get_url_file();
    $image_width = $GLOBALS['generate_doc_thumb'] == 1 ? '' : 'width=100';
    $extension = substr($image_file, strrpos($image_file, "."));
    $viewable_types = array('.png', '.jpg', '.jpeg', '.png', '.bmp', '.PNG', '.JPG', '.JPEG', '.PNG', '.BMP');
    // image ext supported by fancybox viewer
    if (in_array($extension, $viewable_types)) {
        // extention matches list
        $to_url = "<td> <a href = {$web_root}" . "/controller.php?document&retrieve&patient_id={$pid}&document_id={$doc_id}&as_file=false&original_file=true&disable_exit=false&show_original=true" . "/tmp{$extension}" . " onclick=top.restoreSession(); class='image_modal'>" . " <img src = {$web_root}" . "/controller.php?document&retrieve&patient_id={$pid}&document_id={$doc_id}&as_file=false" . " {$image_width} alt='{$doc_catg}:{$image_file}'>  </a> </td> <td valign='center'>" . htmlspecialchars($doc_catg) . '<br />&nbsp;' . htmlspecialchars($image_file) . "</td>";
    } else {
        $to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" . "&patient_id={$pid}&document_id={$doc_id}'" . " onclick='top.restoreSession()' class='css_button_small'>" . "<span>" . htmlspecialchars(xl("View"), ENT_QUOTES) . "</a> &nbsp;" . htmlspecialchars("{$doc_catg} - {$image_file}", ENT_QUOTES) . "</span> </td>";
    }
    echo "<table><tr>";
    echo $to_url;
    echo "</tr></table>";
}
function generate_result_row(&$ctx, &$row, &$rrow, $priors_omitted = false)
{
    $lab_id = empty($row['lab_id']) ? 0 : $row['lab_id'] + 0;
    $order_type_id = empty($row['order_type_id']) ? 0 : $row['order_type_id'] + 0;
    $order_seq = empty($row['procedure_order_seq']) ? 0 : $row['procedure_order_seq'] + 0;
    $report_id = empty($row['procedure_report_id']) ? 0 : $row['procedure_report_id'] + 0;
    $procedure_code = empty($row['procedure_code']) ? '' : $row['procedure_code'];
    $procedure_name = empty($row['procedure_name']) ? '' : $row['procedure_name'];
    $date_report = empty($row['date_report']) ? '' : substr($row['date_report'], 0, 16);
    $date_collected = empty($row['date_collected']) ? '' : substr($row['date_collected'], 0, 16);
    $specimen_num = empty($row['specimen_num']) ? '' : $row['specimen_num'];
    $report_status = empty($row['report_status']) ? '' : $row['report_status'];
    $review_status = empty($row['review_status']) ? 'received' : $row['review_status'];
    $report_noteid = '';
    if ($report_id && !isset($ctx['seen_report_ids'][$report_id])) {
        $ctx['seen_report_ids'][$report_id] = true;
        if ($review_status != 'reviewed') {
            if ($ctx['sign_list']) {
                $ctx['sign_list'] .= ',';
            }
            $ctx['sign_list'] .= $report_id;
        }
        // Allowing for multiple report notes separated by newlines.
        if (!empty($row['report_notes'])) {
            $notes = explode("\n", $row['report_notes']);
            foreach ($notes as $note) {
                if ($note === '') {
                    continue;
                }
                if ($report_noteid) {
                    $report_noteid .= ', ';
                }
                $report_noteid .= 1 + storeNote($note);
            }
        }
    }
    $result_code = empty($rrow['result_code']) ? '' : $rrow['result_code'];
    $result_text = empty($rrow['result_text']) ? '' : $rrow['result_text'];
    $result_abnormal = empty($rrow['abnormal']) ? '' : $rrow['abnormal'];
    $result_result = empty($rrow['result']) ? '' : $rrow['result'];
    $result_units = empty($rrow['units']) ? '' : $rrow['units'];
    $result_facility = empty($rrow['facility']) ? '' : $rrow['facility'];
    $result_comments = empty($rrow['comments']) ? '' : $rrow['comments'];
    $result_range = empty($rrow['range']) ? '' : $rrow['range'];
    $result_status = empty($rrow['result_status']) ? '' : $rrow['result_status'];
    $result_document_id = empty($rrow['document_id']) ? '' : $rrow['document_id'];
    // Someone changed the delimiter in result comments from \n to \r.
    // Have to make sure results are consistent with those before that change.
    $result_comments = str_replace("\r", "\n", $result_comments);
    if ($i = strpos($result_comments, "\n")) {
        // "=" is not a mistake!
        // If the first line of comments is not empty, then it is actually a long textual
        // result value with lines delimited by "~" characters.
        $result_comments = str_replace("~", "\n", substr($result_comments, 0, $i)) . substr($result_comments, $i);
    }
    $result_comments = trim($result_comments);
    $result_noteid = '';
    if (!empty($result_comments)) {
        $result_noteid = 1 + storeNote($result_comments);
    }
    if ($priors_omitted) {
        if ($result_noteid) {
            $result_noteid .= ', ';
        }
        $result_noteid .= 1 + storeNote(xl('This is the latest of multiple result values.'));
        $ctx['priors_omitted'] = true;
    }
    // If a performing organization is provided, make a note for it also.
    $result_facility = trim(str_replace("\r", "\n", $result_facility));
    if ($result_facility) {
        if ($result_noteid) {
            $result_noteid .= ', ';
        }
        $result_noteid .= 1 + storeNote(xl('Performing organization') . ":\n" . $result_facility);
    }
    if ($ctx['lastpcid'] != $order_seq) {
        ++$ctx['encount'];
    }
    $bgcolor = "#" . ($ctx['encount'] & 1 ? "ddddff" : "ffdddd");
    echo " <tr class='detail' bgcolor='{$bgcolor}'>\n";
    if ($ctx['lastpcid'] != $order_seq) {
        $ctx['lastprid'] = -1;
        // force report fields on first line of each procedure
        $tmp = text("{$procedure_code}: {$procedure_name}");
        // Get the LOINC code if one exists in the compendium for this order type.
        if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
            $trow = sqlQuery("SELECT standard_code FROM procedure_type WHERE " . "lab_id = ? AND procedure_code = ? AND procedure_type = 'ord' " . "ORDER BY procedure_type_id LIMIT 1", array($lab_id, $procedure_code));
            if (!empty($trow['standard_code'])) {
                $tmp = "<a href='javascript:educlick(\"LOINC\",\"" . attr($trow['standard_code']) . "\")'>{$tmp}</a>";
            }
        }
        echo "  <td>{$tmp}</td>\n";
    } else {
        echo "  <td style='background-color:transparent'>&nbsp;</td>";
    }
    // If this starts a new report or a new order, generate the report fields.
    if ($report_id != $ctx['lastprid']) {
        echo "  <td>";
        echo myCellText(oeFormatShortDate(substr($date_report, 0, 10)) . substr($date_report, 10));
        echo "</td>\n";
        echo "  <td>";
        echo myCellText(oeFormatShortDate(substr($date_collected, 0, 10)) . substr($date_collected, 10));
        echo "</td>\n";
        echo "  <td>";
        echo myCellText($specimen_num);
        echo "</td>\n";
        echo "  <td title='" . xla('Check mark indicates reviewed') . "'>";
        echo myCellText(getListItem('proc_rep_status', $report_status));
        if ($row['review_status'] == 'reviewed') {
            echo " &#x2713;";
            // unicode check mark character
        }
        echo "</td>\n";
        echo "  <td align='center'>";
        echo myCellText($report_noteid);
        echo "</td>\n";
    } else {
        echo "  <td colspan='5' style='background-color:transparent'>&nbsp;</td>\n";
    }
    if ($result_code !== '' || $result_document_id) {
        $tmp = myCellText($result_code);
        if (empty($GLOBALS['PATIENT_REPORT_ACTIVE']) && !empty($result_code)) {
            $tmp = "<a href='javascript:educlick(\"LOINC\",\"" . attr($result_code) . "\")'>{$tmp}</a>";
        }
        echo "  <td>{$tmp}</td>\n";
        echo "  <td>";
        echo myCellText($result_text);
        echo "</td>\n";
        echo "  <td>";
        $tmp = myCellText(getListItem('proc_res_abnormal', $result_abnormal));
        if ($result_abnormal && strtolower($result_abnormal) != 'no') {
            echo "<b><font color='red'>{$tmp}</font></b>";
        } else {
            echo $tmp;
        }
        echo "</td>\n";
        //
        if ($result_document_id) {
            $d = new Document($result_document_id);
            echo "  <td colspan='3'>";
            if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
                echo "<a href='" . $GLOBALS['webroot'] . "/controller.php?document";
                echo "&retrieve&patient_id={$patient_id}&document_id={$result_document_id}' ";
                echo "onclick='top.restoreSession()'>";
            }
            echo $d->get_url_file();
            if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
                echo "</a>";
            }
            echo "</td>\n";
        } else {
            echo "  <td>";
            echo myCellText($result_result);
            echo "</td>\n";
            echo "  <td>";
            echo myCellText($result_range);
            echo "</td>\n";
            echo "  <td>";
            echo myCellText($result_units);
            echo "</td>\n";
        }
        echo "  <td align='center'>";
        echo myCellText($result_noteid);
        echo "</td>\n";
    } else {
        echo "  <td colspan='7' style='background-color:transparent'>&nbsp;</td>\n";
    }
    echo " </tr>\n";
    $ctx['lastpcid'] = $order_seq;
    $ctx['lastprid'] = $report_id;
    ++$ctx['lino'];
}
function generate_order_report($orderid, $input_form = false)
{
    global $aNotes;
    // Check authorization.
    $thisauth = acl_check('patients', 'med');
    if (!$thisauth) {
        return xl('Not authorized');
    }
    $orow = sqlQuery("SELECT " . "po.procedure_order_id, po.date_ordered, po.control_id, " . "po.order_status, po.specimen_type, po.patient_id, " . "pd.pubpid, pd.lname, pd.fname, pd.mname, pd.cmsportal_login, pd.language, " . "fe.date, " . "pp.name AS labname, " . "u.lname AS ulname, u.fname AS ufname, u.mname AS umname " . "FROM procedure_order AS po " . "LEFT JOIN patient_data AS pd ON pd.pid = po.patient_id " . "LEFT JOIN procedure_providers AS pp ON pp.ppid = po.lab_id " . "LEFT JOIN users AS u ON u.id = po.provider_id " . "LEFT JOIN form_encounter AS fe ON fe.pid = po.patient_id AND fe.encounter = po.encounter_id " . "WHERE po.procedure_order_id = ?", array($orderid));
    $patient_id = $orow['patient_id'];
    $language = $orow['language'];
    ?>

<style>

.labres tr.head   { font-size:10pt; background-color:#cccccc; text-align:center; }
.labres tr.detail { font-size:10pt; }
.labres a, .labres a:visited, .labres a:hover { color:#0000cc; }

.labres table {
 border-style: solid;
 border-width: 1px 0px 0px 1px;
 border-color: black;
}

.labres td, .labres th {
 border-style: solid;
 border-width: 0px 1px 1px 0px;
 border-color: black;
}

</style>

<?php 
    if ($input_form) {
        ?>
<script type="text/javascript" src="<?php 
        echo $GLOBALS['webroot'];
        ?>
/library/textformat.js"></script>
<?php 
    }
    // end if input form
    ?>

<?php 
    if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
        ?>

<script type="text/javascript" src="<?php 
        echo $GLOBALS['webroot'];
        ?>
/library/dialog.js"></script>
<script language="JavaScript">

var mypcc = '<?php 
        echo $GLOBALS['phone_country_code'];
        ?>
';

// Called to show patient notes related to this order in the "other" frame.
// This works even if we are in a separate window.
function showpnotes(orderid) {
 // Find the top or bottom frame that contains or opened this page; return if none.
 var w = window.opener ? window.opener : window;
 for (; w.name != 'RTop' && w.name != 'RBot'; w = w.parent) {
  if (w.parent == w) {
   // This message is not translated because a developer will need to find it.
   alert('Internal error locating target frame in ' + (window.opener ? 'opener' : 'window'));
   return false;
  }
 }
 var othername = (w.name == 'RTop') ? 'RBot' : 'RTop';
 w.parent.left_nav.forceDual();
 w.parent.left_nav.setRadio(othername, 'pno');
 w.parent.left_nav.loadFrame('pno1', othername, 'patient_file/summary/pnotes_full.php?orderid=' + orderid);
 return false;
}

// Process click on LOINC code for patient education popup.
function educlick(codetype, codevalue) {
  dlgopen('<?php 
        echo $GLOBALS['webroot'];
        ?>
/interface/patient_file/education.php' +
    '?type=' + encodeURIComponent(codetype) +
    '&code=' + encodeURIComponent(codevalue) +
    '&language=<?php 
        echo urlencode($language);
        ?>
',
    '_blank', 1024, 750);
}

</script>

<?php 
    }
    // end if not patient report
    ?>

<?php 
    if ($input_form) {
        ?>
<form method='post' action='single_order_results.php?orderid=<?php 
        echo $orderid;
        ?>
'>
<?php 
    }
    // end if input form
    ?>

<div class='labres'>

<table width='100%' cellpadding='2' cellspacing='0'>
 <tr bgcolor='#cccccc'>
  <td width='5%' nowrap><?php 
    echo xlt('Patient ID');
    ?>
</td>
  <td width='45%'><?php 
    echo myCellText($orow['pubpid']);
    ?>
</td>
  <td width='5%' nowrap><?php 
    echo xlt('Order ID');
    ?>
</td>
  <td width='45%'>
<?php 
    if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
        echo "   <a href='" . $GLOBALS['webroot'];
        echo "/interface/orders/order_manifest.php?orderid=";
        echo attr($orow['procedure_order_id']);
        echo "' target='_blank' onclick='top.restoreSession()'>";
    }
    echo myCellText($orow['procedure_order_id']);
    if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
        echo "</a>\n";
    }
    if ($orow['control_id']) {
        echo myCellText(' ' . xl('Lab') . ': ' . $orow['control_id']);
    }
    ?>
  </td>
 </tr>
 <tr bgcolor='#cccccc'>
  <td nowrap><?php 
    echo xlt('Patient Name');
    ?>
</td>
  <td><?php 
    echo myCellText($orow['lname'] . ', ' . $orow['fname'] . ' ' . $orow['mname']);
    ?>
</td>
  <td nowrap><?php 
    echo xlt('Ordered By');
    ?>
</td>
  <td><?php 
    echo myCellText($orow['ulname'] . ', ' . $orow['ufname'] . ' ' . $orow['umname']);
    ?>
</td>
 </tr>
 <tr bgcolor='#cccccc'>
  <td nowrap><?php 
    echo xlt('Order Date');
    ?>
</td>
  <td><?php 
    echo myCellText(oeFormatShortDate($orow['date_ordered']));
    ?>
</td>
  <td nowrap><?php 
    echo xlt('Print Date');
    ?>
</td>
  <td><?php 
    echo oeFormatShortDate(date('Y-m-d'));
    ?>
</td>
 </tr>
 <tr bgcolor='#cccccc'>
  <td nowrap><?php 
    echo xlt('Order Status');
    ?>
</td>
  <td><?php 
    echo myCellText($orow['order_status']);
    ?>
</td>
  <td nowrap><?php 
    echo xlt('Encounter Date');
    ?>
</td>
  <td><?php 
    echo myCellText(oeFormatShortDate(substr($orow['date'], 0, 10)));
    ?>
</td>
 </tr>
 <tr bgcolor='#cccccc'>
  <td nowrap><?php 
    echo xlt('Lab');
    ?>
</td>
  <td><?php 
    echo myCellText($orow['labname']);
    ?>
</td>
  <td nowrap><?php 
    echo xlt('Specimen Type');
    ?>
</td>
  <td><?php 
    echo myCellText($orow['specimen_type']);
    ?>
</td>
 </tr>
</table>

&nbsp;<br />

<table width='100%' cellpadding='2' cellspacing='0'>

 <tr class='head'>
  <td rowspan='2' valign='middle'><?php 
    echo xlt('Ordered Procedure');
    ?>
</td>
  <td colspan='4'><?php 
    echo xlt('Report');
    ?>
</td>
  <td colspan='7'><?php 
    echo xlt('Results');
    ?>
</td>
 </tr>

 <tr class='head'>
  <td><?php 
    echo xlt('Reported');
    ?>
</td>
  <td><?php 
    echo xlt('Specimen');
    ?>
</td>
  <td><?php 
    echo xlt('Status');
    ?>
</td>
  <td><?php 
    echo xlt('Note');
    ?>
</td>
  <td><?php 
    echo xlt('Code');
    ?>
</td>
  <td><?php 
    echo xlt('Name');
    ?>
</td>
  <td><?php 
    echo xlt('Abn');
    ?>
</td>
  <td><?php 
    echo xlt('Value');
    ?>
</td>
  <td><?php 
    echo xlt('Range');
    ?>
</td>
  <td><?php 
    echo xlt('Units');
    ?>
</td>
  <td><?php 
    echo xlt('Note');
    ?>
</td>
 </tr>

<?php 
    $query = "SELECT " . "po.lab_id, po.date_ordered, pc.procedure_order_seq, pc.procedure_code, " . "pc.procedure_name, " . "pr.procedure_report_id, pr.date_report, pr.date_collected, pr.specimen_num, " . "pr.report_status, pr.review_status, pr.report_notes " . "FROM procedure_order AS po " . "JOIN procedure_order_code AS pc ON pc.procedure_order_id = po.procedure_order_id " . "LEFT JOIN procedure_report AS pr ON pr.procedure_order_id = po.procedure_order_id AND " . "pr.procedure_order_seq = pc.procedure_order_seq " . "WHERE po.procedure_order_id = ? " . "ORDER BY pc.procedure_order_seq, pr.procedure_report_id";
    $res = sqlStatement($query, array($orderid));
    $lastpoid = -1;
    $lastpcid = -1;
    $lastprid = -1;
    $encount = 0;
    $lino = 0;
    $extra_html = '';
    $aNotes = array();
    $sign_list = '';
    while ($row = sqlFetchArray($res)) {
        $lab_id = empty($row['lab_id']) ? 0 : $row['lab_id'] + 0;
        $order_type_id = empty($row['order_type_id']) ? 0 : $row['order_type_id'] + 0;
        $order_seq = empty($row['procedure_order_seq']) ? 0 : $row['procedure_order_seq'] + 0;
        $report_id = empty($row['procedure_report_id']) ? 0 : $row['procedure_report_id'] + 0;
        $procedure_code = empty($row['procedure_code']) ? '' : $row['procedure_code'];
        $procedure_name = empty($row['procedure_name']) ? '' : $row['procedure_name'];
        $date_report = empty($row['date_report']) ? '' : $row['date_report'];
        $date_collected = empty($row['date_collected']) ? '' : substr($row['date_collected'], 0, 16);
        $specimen_num = empty($row['specimen_num']) ? '' : $row['specimen_num'];
        $report_status = empty($row['report_status']) ? '' : $row['report_status'];
        $review_status = empty($row['review_status']) ? 'received' : $row['review_status'];
        if ($review_status != 'reviewed' && $report_id) {
            if ($sign_list) {
                $sign_list .= ',';
            }
            $sign_list .= $report_id;
        }
        $report_noteid = '';
        if (!empty($row['report_notes'])) {
            $report_noteid = 1 + storeNote($row['report_notes']);
        }
        $query = "SELECT " . "ps.result_code, ps.result_text, ps.abnormal, ps.result, ps.range, " . "ps.result_status, ps.facility, ps.units, ps.comments, ps.document_id " . "FROM procedure_result AS ps " . "WHERE ps.procedure_report_id = ? " . "ORDER BY ps.result_code, ps.procedure_result_id";
        $rres = sqlStatement($query, array($report_id));
        $rrows = array();
        while ($rrow = sqlFetchArray($rres)) {
            $rrows[] = $rrow;
        }
        if (empty($rrows)) {
            $rrows[0] = array('result_code' => '');
        }
        foreach ($rrows as $rrow) {
            $result_code = empty($rrow['result_code']) ? '' : $rrow['result_code'];
            $result_text = empty($rrow['result_text']) ? '' : $rrow['result_text'];
            $result_abnormal = empty($rrow['abnormal']) ? '' : $rrow['abnormal'];
            $result_result = empty($rrow['result']) ? '' : $rrow['result'];
            $result_units = empty($rrow['units']) ? '' : $rrow['units'];
            $result_facility = empty($rrow['facility']) ? '' : $rrow['facility'];
            $result_comments = empty($rrow['comments']) ? '' : $rrow['comments'];
            $result_range = empty($rrow['range']) ? '' : $rrow['range'];
            $result_status = empty($rrow['result_status']) ? '' : $rrow['result_status'];
            $result_document_id = empty($rrow['document_id']) ? '' : $rrow['document_id'];
            $result_comments = trim($result_comments);
            $result_noteid = '';
            if (!empty($result_comments)) {
                $result_noteid = 1 + storeNote($result_comments);
            }
            if ($lastpoid != $order_id || $lastpcid != $order_seq) {
                ++$encount;
            }
            $bgcolor = "#" . ($encount & 1 ? "ddddff" : "ffdddd");
            echo " <tr class='detail' bgcolor='{$bgcolor}'>\n";
            if ($lastpcid != $order_seq) {
                $lastprid = -1;
                // force report fields on first line of each procedure
                $tmp = text("{$procedure_code}: {$procedure_name}");
                // Get the LOINC code if one exists in the compendium for this order type.
                if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
                    $trow = sqlQuery("SELECT standard_code FROM procedure_type WHERE " . "lab_id = ? AND procedure_code = ? AND procedure_type = 'ord' " . "ORDER BY procedure_type_id LIMIT 1", array($lab_id, $procedure_code));
                    if (!empty($trow['standard_code'])) {
                        $tmp = "<a href='javascript:educlick(\"LOINC\",\"" . attr($trow['standard_code']) . "\")'>{$tmp}</a>";
                    }
                }
                echo "  <td>{$tmp}</td>\n";
            } else {
                echo "  <td style='background-color:transparent'>&nbsp;</td>";
            }
            // If this starts a new report or a new order, generate the report fields.
            if ($report_id != $lastprid) {
                echo "  <td>";
                echo myCellText(oeFormatShortDate($date_report));
                echo "</td>\n";
                echo "  <td>";
                echo myCellText($specimen_num);
                echo "</td>\n";
                echo "  <td title='" . xla('Check mark indicates reviewed') . "'>";
                echo myCellText(getListItem('proc_rep_status', $report_status));
                if ($row['review_status'] == 'reviewed') {
                    echo " &#x2713;";
                    // unicode check mark character
                }
                echo "</td>\n";
                echo "  <td align='center'>";
                echo myCellText($report_noteid);
                echo "</td>\n";
            } else {
                echo "  <td colspan='4' style='background-color:transparent'>&nbsp;</td>\n";
            }
            if ($result_code !== '' || $result_document_id) {
                $tmp = myCellText($result_code);
                if (empty($GLOBALS['PATIENT_REPORT_ACTIVE']) && !empty($result_code)) {
                    $tmp = "<a href='javascript:educlick(\"LOINC\",\"" . attr($result_code) . "\")'>{$tmp}</a>";
                }
                echo "  <td>{$tmp}</td>\n";
                echo "  <td>";
                echo myCellText($result_text);
                echo "</td>\n";
                echo "  <td>";
                echo myCellText(getListItem('proc_res_abnormal', $result_abnormal));
                echo "</td>\n";
                //
                if ($result_document_id) {
                    $d = new Document($result_document_id);
                    echo "  <td colspan='3'>";
                    if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
                        echo "<a href='" . $GLOBALS['webroot'] . "/controller.php?document";
                        echo "&retrieve&patient_id={$patient_id}&document_id={$result_document_id}' ";
                        echo "onclick='top.restoreSession()'>";
                    }
                    echo $d->get_url_file();
                    if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
                        echo "</a>";
                    }
                    echo "</td>\n";
                } else {
                    echo "  <td>";
                    echo myCellText($result_result);
                    echo "</td>\n";
                    echo "  <td>";
                    echo myCellText($result_range);
                    echo "</td>\n";
                    echo "  <td>";
                    echo myCellText($result_units);
                    echo "</td>\n";
                }
                echo "  <td align='center'>";
                echo myCellText($result_noteid);
                echo "</td>\n";
            } else {
                echo "  <td colspan='7' style='background-color:transparent'>&nbsp;</td>\n";
            }
            echo " </tr>\n";
            $lastpoid = $order_id;
            $lastpcid = $order_seq;
            $lastprid = $report_id;
            ++$lino;
        }
    }
    ?>

</table>

&nbsp;<br />
<table width='100%' style='border-width:0px;'>
 <tr>
  <td style='border-width:0px;'>
<?php 
    if (!empty($aNotes)) {
        echo "<table cellpadding='3' cellspacing='0'>\n";
        echo " <tr bgcolor='#cccccc'>\n";
        echo "  <th align='center' colspan='2'>" . xlt('Notes') . "</th>\n";
        echo " </tr>\n";
        foreach ($aNotes as $key => $value) {
            echo " <tr>\n";
            echo "  <td valign='top'>" . ($key + 1) . "</td>\n";
            echo "  <td>" . nl2br(text($value)) . "</td>\n";
            echo " </tr>\n";
        }
        echo "</table>\n";
    }
    ?>
  </td>
  <td style='border-width:0px;' align='right' valign='top'>
<?php 
    if (empty($GLOBALS['PATIENT_REPORT_ACTIVE'])) {
        ?>
   <input type='button' value='<?php 
        echo xla('Related Patient Notes');
        ?>
' 
    onclick='showpnotes(<?php 
        echo $orderid;
        ?>
)' />
<?php 
    }
    if ($input_form && $sign_list) {
        ?>
   &nbsp;
   <input type='hidden' name='form_sign_list' value='<?php 
        echo attr($sign_list);
        ?>
' />
   <input type='submit' name='form_sign' value='<?php 
        echo xla('Sign Results');
        ?>
'
    title='<?php 
        echo xla('Mark these reports as reviewed');
        ?>
' />
<?php 
        // If this is a portal patient, sending them a copy is an option.
        if ($GLOBALS['gbl_portal_cms_enable'] && $orow['cmsportal_login'] !== '') {
            echo "&nbsp;";
            echo "<input type='checkbox' name='form_send_to_portal' value='" . attr($orow['cmsportal_login']) . "' checked />\n";
            echo xlt('Send to portal');
        }
    }
    if ($input_form) {
        ?>
   &nbsp;
   <input type='button' value='<?php 
        echo xla('Close');
        ?>
' onclick='window.close()' />
<?php 
    }
    ?>
  </td>
 </tr>
</table>

</div>

<?php 
    if ($input_form) {
        ?>
</form>
<?php 
    }
    // end if input form
    ?>

<?php 
}
Ejemplo n.º 10
0
 }
 if (empty($sprow['DOB']) || $sprow['DOB'] == '0000-00-00') {
     die(xlt('Source patient has no DOB'));
 }
 if ($tprow['DOB'] != $sprow['DOB']) {
     die(xlt('Target and source DOB do not match'));
 }
 $tdocdir = "{$OE_SITE_DIR}/documents/{$target_pid}";
 $sdocdir = "{$OE_SITE_DIR}/documents/{$source_pid}";
 $sencdir = "{$sdocdir}/encounters";
 $tencdir = "{$tdocdir}/encounters";
 // Change normal documents first as that could fail if CouchDB connection fails.
 $dres = sqlStatement("SELECT * FROM `documents` WHERE `foreign_id` = '{$source_pid}'");
 while ($drow = sqlFetchArray($dres)) {
     $d = new Document($drow['id']);
     echo "<br />" . xlt('Changing patient ID for document') . ' ' . text($d->get_url_file());
     if ($PRODUCTION) {
         if (!$d->change_patient($target_pid)) {
             die("<br />" . xlt('Change failed! CouchDB connect error?'));
         }
     }
 }
 // Move scanned encounter documents and delete their container.
 if (is_dir($sencdir)) {
     if ($PRODUCTION && !file_exists($tdocdir)) {
         mkdir($tdocdir);
     }
     if ($PRODUCTION && !file_exists($tencdir)) {
         mkdir($tencdir);
     }
     $dh = opendir($sencdir);
Ejemplo n.º 11
0
function image_widget($doc_id,$doc_catg)
{
        global $pid, $web_root;
        $docobj = new Document($doc_id);
        $image_file = $docobj->get_url_file();
        $extension = substr($image_file, strrpos($image_file,"."));
        $viewable_types = array('.png','.jpg','.jpeg','.png','.bmp','.PNG','.JPG','.JPEG','.PNG','.BMP'); // image ext supported by fancybox viewer
        if ( in_array($extension,$viewable_types) ) { // extention matches list
                $to_url = "<td> <a href = $web_root" .
				"/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
				"/tmp$extension" .  // Force image type URL for fancybox
				" onclick=top.restoreSession(); class='image_modal'>" .
                " <img src = $web_root" .
				"/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
				" width=100 alt='$doc_catg:$image_file'>  </a> </td> <td valign='center'>".
                htmlspecialchars($doc_catg) . '<br />&nbsp;' . htmlspecialchars($image_file) .
				"</td>";
        }
     	else {
				$to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
                    "&patient_id=$pid&document_id=$doc_id'" .
                    " onclick='top.restoreSession()' class='css_button_small'>" .
                    "<span>" .
                    htmlspecialchars( xl("View"), ENT_QUOTES )."</a> &nbsp;" . 
					htmlspecialchars( "$doc_catg - $image_file", ENT_QUOTES ) .
                    "</span> </td>";
		}
        echo "<table><tr>";
        echo $to_url;
        echo "</tr></table>";
}
Ejemplo n.º 12
0
 function move_action_process($patient_id = "", $document_id)
 {
     if ($_POST['process'] != "true") {
         return;
     }
     $new_category_id = $_POST['new_category_id'];
     $new_patient_id = $_POST['new_patient_id'];
     //move to new category
     if (is_numeric($new_category_id) && is_numeric($document_id)) {
         $sql = "UPDATE categories_to_documents set category_id = '" . $new_category_id . "' where document_id = '" . $document_id . "'";
         $messages .= xl('Document moved to new category', '', '', ' \'') . $this->tree->_id_name[$new_category_id]['name'] . xl('successfully.', '', '\' ') . "\n";
         //echo $sql;
         $this->tree->_db->Execute($sql);
     }
     //move to new patient
     if (is_numeric($new_patient_id) && is_numeric($document_id)) {
         $d = new Document($document_id);
         // $sql = "SELECT pid from patient_data where pubpid = '" . $new_patient_id . "'";
         $sql = "SELECT pid from patient_data where pid = '" . $new_patient_id . "'";
         $result = $d->_db->Execute($sql);
         if (!$result || $result->EOF) {
             //patient id does not exist
             $messages .= xl('Document could not be moved to patient id', '', '', ' \'') . $new_patient_id . xl('because that id does not exist.', '', '\' ') . "\n";
         } else {
             //set the new patient
             $d->set_foreign_id($new_patient_id);
             $d->persist();
             $this->_state = false;
             $messages .= xl('Document moved to patient id', '', '', ' \'') . $new_patient_id . xl('successfully.', '', '\' ') . "\n";
             $this->assign("messages", $messages);
             return $this->list_action($patient_id);
         }
     } elseif (strtolower($new_patient_id) == "q" && is_numeric($document_id)) {
         $d = new Document($document_id);
         $new_path = $this->_config['repository'];
         $fname = $d->get_url_file();
         //see if there is an existing file with the same name and rename as necessary
         if (file_exists($new_path . $d->get_url_file())) {
             $messages .= "File with same name already exists in the queue.\n";
             $fname = basename($this->_rename_file($new_path . $d->get_url_file()));
             $messages .= "Current file name was changed to " . $fname . "\n";
         }
         //now move the file
         if (rename($d->get_url_filepath(), $new_path . $fname)) {
             $d->url = "file://" . $new_path . $fname;
             $d->set_foreign_id("");
             $d->persist();
             $d->persist();
             $d->populate();
             $sql = "DELETE FROM categories_to_documents where document_id =" . $d->_db->qstr($document_id);
             $d->_db->Execute($sql);
             $messages .= "Document returned to queue successfully.\n";
         } else {
             $messages .= "The file could not be succesfully stored, this error is usually related to permissions problems on the storage system.\n";
         }
         $this->_state = false;
         $this->assign("messages", $messages);
         return $this->list_action($patient_id);
     }
     $this->_state = false;
     $this->assign("messages", $messages);
     return $this->view_action($patient_id, $document_id);
 }
Ejemplo n.º 13
0
       </div>


	</div>
    <!-- end left column div -->

    <!-- start right column div -->
	<div class='text'>
    <table>
    <tr>
    <td>
    <?php 
// If there is a patient ID card, then show a link to it.
if ($document_id) {
    $docobj = new Document($document_id);
    $image_file = $docobj->get_url_file();
    // File ends in .pdf
    if (preg_match('/\\.pdf$/i', $image_file)) {
        echo "<a href='" . $web_root . "/controller.php?document&retrieve" . "&patient_id={$pid}&document_id={$document_id}'" . " onclick='top.restoreSession()'>" . xl("Click for ID card") . "</a><br />";
    } else {
        // image file type(s) std list png, jpg, etc...
        echo "<a href='" . $web_root . "/sites/" . $_SESSION['site_id'] . "/documents/{$pid}/{$image_file}'" . " onclick='top.restoreSession()' class='iframe image_view_modal'>" . xl("Click to View ID card") . "</a><br />";
    }
}
// Advance Directives
if ($GLOBALS['advance_directives_warning']) {
    // advance directives expand collapse widget
    $widgetTitle = xl("Advance Directives");
    $widgetLabel = "directives";
    $widgetButtonLabel = xl("Edit");
    $widgetButtonLink = "return advdirconfigure();";