From 400905dd2a15dda56ada616f7e139b3b3c2410dc Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Tue, 2 Dec 2008 17:39:19 +0000 Subject: [PATCH] added support for the scanned_notes encounter form --- interface/fax/fax_dispatch.php | 663 ++++++++++++++++++++-------------- interface/fax/fax_dispatch_newpid.php | 30 ++ 2 files changed, 424 insertions(+), 269 deletions(-) create mode 100644 interface/fax/fax_dispatch_newpid.php diff --git a/interface/fax/fax_dispatch.php b/interface/fax/fax_dispatch.php index cc412d62a..48e6805ad 100644 --- a/interface/fax/fax_dispatch.php +++ b/interface/fax/fax_dispatch.php @@ -1,54 +1,55 @@ - // - // This program is free software; you can redistribute it and/or - // modify it under the terms of the GNU General Public License - // as published by the Free Software Foundation; either version 2 - // of the License, or (at your option) any later version. - - include_once("../globals.php"); - include_once("$srcdir/patient.inc"); - include_once("$srcdir/pnotes.inc"); - - if ($_GET['file']) { +// Copyright (C) 2006-2008 Rod Roark +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +include_once("../globals.php"); +include_once("$srcdir/patient.inc"); +include_once("$srcdir/pnotes.inc"); +include_once("$srcdir/forms.inc"); + +if ($_GET['file']) { $mode = 'fax'; $filename = $_GET['file']; $filepath = $GLOBALS['hylafax_basedir'] . '/recvq/' . $filename; - } - else if ($_GET['scan']) { +} +else if ($_GET['scan']) { $mode = 'scan'; $filename = $_GET['scan']; $filepath = $GLOBALS['scanner_output_directory'] . '/' . $filename; - } - else { +} +else { die("No filename was given."); - } +} - $ext = substr($filename, strrpos($filename, '.')); - $filebase = basename("/$filename", $ext); - $faxcache = "$webserver_root/faxcache/$mode/$filebase"; +$ext = substr($filename, strrpos($filename, '.')); +$filebase = basename("/$filename", $ext); +$faxcache = "$webserver_root/faxcache/$mode/$filebase"; - $info_msg = ""; +$info_msg = ""; - // This function builds an array of document categories recursively. - // Kittens are the children of cats, you know. :-) - // - function getKittens($catid, $catstring, &$categories) { +// This function builds an array of document categories recursively. +// Kittens are the children of cats, you know. :-) +// +function getKittens($catid, $catstring, &$categories) { $cres = sqlStatement("SELECT id, name FROM categories " . - "WHERE parent = $catid ORDER BY name"); + "WHERE parent = $catid ORDER BY name"); $childcount = 0; while ($crow = sqlFetchArray($cres)) { - ++$childcount; - getKittens($crow['id'], ($catstring ? "$catstring / " : "") . - ($catid ? $crow['name'] : ''), $categories); + ++$childcount; + getKittens($crow['id'], ($catstring ? "$catstring / " : "") . + ($catid ? $crow['name'] : ''), $categories); } // If no kitties, then this is a leaf node and should be listed. if (!$childcount) $categories[$catid] = $catstring; - } +} - // This merges the tiff files for the selected pages into one tiff file. - // - function mergeTiffs() { +// This merges the tiff files for the selected pages into one tiff file. +// +function mergeTiffs() { global $faxcache; $msg = ''; $inames = ''; @@ -56,241 +57,309 @@ $tmp2 = 0; // form_images are the checkboxes to the right of the images. foreach ($_POST['form_images'] as $inbase) { - $inames .= ' ' . escapeshellarg("$inbase.tif"); + $inames .= ' ' . escapeshellarg("$inbase.tif"); } if (!$inames) die(xl("Internal error - no pages were selected!")); $tmp0 = exec("cd '$faxcache'; tiffcp $inames temp.tif", $tmp1, $tmp2); if ($tmp2) { - $msg .= "tiffcp returned $tmp2: $tmp0 "; + $msg .= "tiffcp returned $tmp2: $tmp0 "; } return $msg; - } +} - // If we are submitting... - // - if ($_POST['form_save']) { +// If we are submitting... +// +if ($_POST['form_save']) { $action_taken = false; $tmp1 = array(); $tmp2 = 0; if ($_POST['form_cb_copy']) { - $patient_id = (int) $_POST['form_pid']; - if (!$patient_id) die(xl('Internal error - patient ID was not provided!')); - // Compute the name of the target directory and make sure it exists. - $docdir = "$webserver_root/documents/$patient_id"; - exec("mkdir -p '$docdir'"); - // Compute a target filename that does not yet exist. - $ffname = trim($_POST['form_filename']); - $i = strrpos($ffname, '.'); - if ($i) $ffname = trim(substr($ffname, 0, $i)); - if (!$ffname) $ffname = $filebase; - $ffmod = ''; - $ffsuff = '.pdf'; - // If the target filename exists, modify it until it doesn't. - $count = 0; - while (is_file("$docdir/$ffname$ffmod$ffsuff")) { - ++$count; - $ffmod = "_$count"; - } - $target = "$docdir/$ffname$ffmod$ffsuff"; - - $docdate = fixDate($_POST['form_docdate']); - - // Create the target PDF. Note that we are relying on the .tif files for - // the individual pages to already exist in the faxcache directory. - // - $info_msg .= mergeTiffs(); - $tmp0 = exec("tiff2pdf -p letter -o '$target' '$faxcache/temp.tif'", $tmp1, $tmp2); - if ($tmp2) { - $info_msg .= "tiff2pdf returned $tmp2: $tmp0 "; - } - else { - $newid = generate_id(); - $fsize = filesize($target); - $catid = (int) $_POST['form_category']; - // Update the database. - $query = "INSERT INTO documents ( " . - "id, type, size, date, url, mimetype, foreign_id, docdate" . - " ) VALUES ( " . - "'$newid', 'file_url', '$fsize', NOW(), 'file://$target', " . - "'application/pdf', $patient_id, '$docdate' " . - ")"; - sqlStatement($query); - $query = "INSERT INTO categories_to_documents ( " . - "category_id, document_id" . - " ) VALUES ( " . - "'$catid', '$newid' " . - ")"; - sqlStatement($query); - - // If we are posting a note... - if ($_POST['form_cb_note']) { - // Build note text in a way that identifies the new document. - // See pnotes_full.php which uses this to auto-display the document. - $note = "$ffname$ffmod$ffsuff"; - for ($tmp = $catid; $tmp;) { - $catrow = sqlQuery("SELECT name, parent FROM categories WHERE id = '$tmp'"); - $note = $catrow['name'] . "/$note"; - $tmp = $catrow['parent']; - } - $note = "New scanned document $newid: $note"; - $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($_POST['form_pid'], $note, $userauthorized, '1', - $_POST['form_note_type'], $_POST['form_note_to']); + $patient_id = (int) $_POST['form_pid']; + if (!$patient_id) die(xl('Internal error - patient ID was not provided!')); + // Compute the name of the target directory and make sure it exists. + $docdir = "$webserver_root/documents/$patient_id"; + exec("mkdir -p '$docdir'"); + + // If copying to patient documents... + // + if ($_POST['form_cb_copy_type'] == 1) { + // Compute a target filename that does not yet exist. + $ffname = trim($_POST['form_filename']); + $i = strrpos($ffname, '.'); + if ($i) $ffname = trim(substr($ffname, 0, $i)); + if (!$ffname) $ffname = $filebase; + $ffmod = ''; + $ffsuff = '.pdf'; + // If the target filename exists, modify it until it doesn't. + $count = 0; + while (is_file("$docdir/$ffname$ffmod$ffsuff")) { + ++$count; + $ffmod = "_$count"; + } + $target = "$docdir/$ffname$ffmod$ffsuff"; + $docdate = fixDate($_POST['form_docdate']); + + // Create the target PDF. Note that we are relying on the .tif files for + // the individual pages to already exist in the faxcache directory. + // + $info_msg .= mergeTiffs(); + // The -j option here requires that libtiff is configured with libjpeg. + // It could be omitted, but the output PDFs would then be quite large. + $tmp0 = exec("tiff2pdf -j -p letter -o '$target' '$faxcache/temp.tif'", $tmp1, $tmp2); + + if ($tmp2) { + $info_msg .= "tiff2pdf returned $tmp2: $tmp0 "; + } + else { + $newid = generate_id(); + $fsize = filesize($target); + $catid = (int) $_POST['form_category']; + // Update the database. + $query = "INSERT INTO documents ( " . + "id, type, size, date, url, mimetype, foreign_id, docdate" . + " ) VALUES ( " . + "'$newid', 'file_url', '$fsize', NOW(), 'file://$target', " . + "'application/pdf', $patient_id, '$docdate' " . + ")"; + sqlStatement($query); + $query = "INSERT INTO categories_to_documents ( " . + "category_id, document_id" . + " ) VALUES ( " . + "'$catid', '$newid' " . + ")"; + sqlStatement($query); + } // end not error + + // If we are posting a note... + if ($_POST['form_cb_note'] && !$info_msg) { + // Build note text in a way that identifies the new document. + // See pnotes_full.php which uses this to auto-display the document. + $note = "$ffname$ffmod$ffsuff"; + for ($tmp = $catid; $tmp;) { + $catrow = sqlQuery("SELECT name, parent FROM categories WHERE id = '$tmp'"); + $note = $catrow['name'] . "/$note"; + $tmp = $catrow['parent']; + } + $note = "New scanned document $newid: $note"; + $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($_POST['form_pid'], $note, $userauthorized, '1', + $_POST['form_note_type'], $_POST['form_note_to']); + } // end post patient note + } // end copy to documents + + // Otherwise creating a scanned encounter note... + // + else { + + // Get desired $encounter_id. + $encounter_id = 0; + if (empty($_POST['form_copy_sn_visit'])) { + $info_msg .= "This patient has no visits! "; + } else { + $encounter_id = 0 + $_POST['form_copy_sn_visit']; + } + + if (!$info_msg) { + // Merge the selected pages. + $info_msg .= mergeTiffs(); + $tmp_name = "$faxcache/temp.tif"; + } + + if (!$info_msg) { + // The following is cloned from contrib/forms/scanned_notes/new.php: + // + $query = "INSERT INTO form_scanned_notes ( " . + "notes " . + ") VALUES ( " . + "'" . $_POST['form_copy_sn_comments'] . "' " . + ")"; + $formid = sqlInsert($query); + addForm($encounter_id, "Scanned Notes", $formid, "scanned_notes", + $patient_id, $userauthorized); + // + $imagedir = "$webserver_root/documents/$patient_id/encounters"; + $imagepath = "$imagedir/${encounter_id}_$formid.jpg"; + // + if (! is_dir($imagedir)) { + $tmp0 = exec("mkdir -p '$imagedir'", $tmp1, $tmp2); + if ($tmp2) die("mkdir returned $tmp2: $tmp0"); + exec("touch '$imagedir/index.html'"); + } + if (is_file($imagepath)) unlink($imagepath); + // TBD: There may be a faster way to create this file, given that + // we already have a jpeg for each page in faxcache. + $cmd = "convert -resize 800 -density 96 '$tmp_name' -append '$imagepath'"; + $tmp0 = exec($cmd, $tmp1, $tmp2); + 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); - $form_message = stripslashes($form_message); - } + $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); + $form_message = stripslashes($form_message); + } - // Generate a cover page using enscript. This can be a cool thing - // to do, as enscript is very powerful. - // - $tmp1 = array(); - $tmp2 = 0; - $tmpfn1 = tempnam("/tmp", "fax1"); - $tmpfn2 = tempnam("/tmp", "fax2"); - $tmph = fopen($tmpfn1, "w"); - $cpstring = ''; - $fh = fopen("$webserver_root/custom/faxcover.txt", 'r'); - while (!feof($fh)) $cpstring .= fread($fh, 8192); - fclose($fh); - $cpstring = str_replace('{CURRENT_DATE}' , date('F j, Y'), $cpstring); - $cpstring = str_replace('{SENDER_NAME}' , $form_from , $cpstring); - $cpstring = str_replace('{RECIPIENT_NAME}', $form_to , $cpstring); - $cpstring = str_replace('{RECIPIENT_FAX}' , $form_fax , $cpstring); - $cpstring = str_replace('{MESSAGE}' , $form_message , $cpstring); - fwrite($tmph, $cpstring); - fclose($tmph); - $tmp0 = exec("cd $webserver_root/custom; " . $GLOBALS['hylafax_enscript'] . - " -o $tmpfn2 $tmpfn1", $tmp1, $tmp2); - if ($tmp2) { - $info_msg .= "enscript returned $tmp2: $tmp0 "; - } - unlink($tmpfn1); - - // Send the fax as the cover page followed by the selected pages. - $info_msg .= mergeTiffs(); - $tmp0 = exec("sendfax -A -n $form_finemode -d " . - escapeshellarg($form_fax) . " $tmpfn2 '$faxcache/temp.tif'", - $tmp1, $tmp2); - if ($tmp2) { - $info_msg .= "sendfax returned $tmp2: $tmp0 "; - } - unlink($tmpfn2); + // Generate a cover page using enscript. This can be a cool thing + // to do, as enscript is very powerful. + // + $tmp1 = array(); + $tmp2 = 0; + $tmpfn1 = tempnam("/tmp", "fax1"); + $tmpfn2 = tempnam("/tmp", "fax2"); + $tmph = fopen($tmpfn1, "w"); + $cpstring = ''; + $fh = fopen("$webserver_root/custom/faxcover.txt", 'r'); + while (!feof($fh)) $cpstring .= fread($fh, 8192); + fclose($fh); + $cpstring = str_replace('{CURRENT_DATE}' , date('F j, Y'), $cpstring); + $cpstring = str_replace('{SENDER_NAME}' , $form_from , $cpstring); + $cpstring = str_replace('{RECIPIENT_NAME}', $form_to , $cpstring); + $cpstring = str_replace('{RECIPIENT_FAX}' , $form_fax , $cpstring); + $cpstring = str_replace('{MESSAGE}' , $form_message , $cpstring); + fwrite($tmph, $cpstring); + fclose($tmph); + $tmp0 = exec("cd $webserver_root/custom; " . $GLOBALS['hylafax_enscript'] . + " -o $tmpfn2 $tmpfn1", $tmp1, $tmp2); + if ($tmp2) { + $info_msg .= "enscript returned $tmp2: $tmp0 "; + } + unlink($tmpfn1); + + // Send the fax as the cover page followed by the selected pages. + $info_msg .= mergeTiffs(); + $tmp0 = exec("sendfax -A -n $form_finemode -d " . + escapeshellarg($form_fax) . " $tmpfn2 '$faxcache/temp.tif'", + $tmp1, $tmp2); + if ($tmp2) { + $info_msg .= "sendfax returned $tmp2: $tmp0 "; + } + unlink($tmpfn2); - $action_taken = true; - } + $action_taken = true; + } // end forward $form_cb_delete = $_POST['form_cb_delete']; // If deleting selected, do it and then check if any are left. if ($form_cb_delete == '1' && !$info_msg) { - foreach ($_POST['form_images'] as $inbase) { - unlink("$faxcache/$inbase.jpg"); - $action_taken = true; - } - // Check if any .jpg files remain... if not we'll clean up. - if ($action_taken) { - $dh = opendir($faxcache); - if (! $dh) die("Cannot read $faxcache"); - $form_cb_delete = '2'; - while (false !== ($jfname = readdir($dh))) { - if (preg_match('/\.jpg$/', $jfname)) $form_cb_delete = '1'; + foreach ($_POST['form_images'] as $inbase) { + unlink("$faxcache/$inbase.jpg"); + $action_taken = true; } - closedir($dh); - } - } + // Check if any .jpg files remain... if not we'll clean up. + if ($action_taken) { + $dh = opendir($faxcache); + if (! $dh) die("Cannot read $faxcache"); + $form_cb_delete = '2'; + while (false !== ($jfname = readdir($dh))) { + if (preg_match('/\.jpg$/', $jfname)) $form_cb_delete = '1'; + } + closedir($dh); + } + } // end delete 1 if ($form_cb_delete == '2' && !$info_msg) { - - // Delete the tiff file, with archiving if desired. - if ($GLOBALS['hylafax_archdir'] && $mode == 'fax') { - rename($filepath, $GLOBALS['hylafax_archdir'] . '/' . $filename); - } else { - unlink($filepath); - } - - // Erase its cache. - if (is_dir($faxcache)) { - $dh = opendir($faxcache); - while (($tmp = readdir($dh)) !== false) { - if (is_file("$faxcache/$tmp")) unlink("$faxcache/$tmp"); + // Delete the tiff file, with archiving if desired. + if ($GLOBALS['hylafax_archdir'] && $mode == 'fax') { + rename($filepath, $GLOBALS['hylafax_archdir'] . '/' . $filename); + } else { + unlink($filepath); } - closedir($dh); - rmdir($faxcache); - } - - $action_taken = true; - } + // Erase its cache. + if (is_dir($faxcache)) { + $dh = opendir($faxcache); + while (($tmp = readdir($dh)) !== false) { + if (is_file("$faxcache/$tmp")) unlink("$faxcache/$tmp"); + } + closedir($dh); + rmdir($faxcache); + } + $action_taken = true; + } // end delete 2 if (!$action_taken && !$info_msg) - $info_msg = xl('You did not choose any actions.'); + $info_msg = xl('You did not choose any actions.'); if ($info_msg || $form_cb_delete != '1') { - // Close this window and refresh the fax list. - echo "\n\n\n\n\n"; - exit(); + // Close this window and refresh the fax list. + echo "\n\n\n\n\n"; + exit(); } +} // end submit logic - } +// If we get this far then we are displaying the form. - // If we get this far then we are displaying the form. +// Find out if the scanned_notes form is installed and active. +// +$tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " . + "directory LIKE 'scanned_notes' AND state = 1 AND sql_run = 1"); +$using_scanned_notes = $tmp['count']; - // If the image cache does not yet exist for this fax, build it. - // This will contain a .tif image as well as a .jpg image for each page. - // - if (! is_dir($faxcache)) { +// If the image cache does not yet exist for this fax, build it. +// This will contain a .tif image as well as a .jpg image for each page. +// +if (! is_dir($faxcache)) { $tmp0 = exec("mkdir -p '$faxcache'", $tmp1, $tmp2); if ($tmp2) die("mkdir returned $tmp2: $tmp0"); if (strtolower($ext) != '.tif') { - // convert's default density for PDF-to-TIFF conversion is 72 dpi which is - // not very good, so we upgrade it to "fine mode" fax quality. It's really - // better and faster if the scanner produces TIFFs instead of PDFs. - $tmp0 = exec("convert -density 203x196 '$filepath' '$faxcache/deleteme.tif'", $tmp1, $tmp2); - if ($tmp2) die("convert returned $tmp2: $tmp0"); - $tmp0 = exec("cd '$faxcache'; tiffsplit 'deleteme.tif'; rm -f 'deleteme.tif'", $tmp1, $tmp2); - if ($tmp2) die("tiffsplit/rm returned $tmp2: $tmp0"); + // convert's default density for PDF-to-TIFF conversion is 72 dpi which is + // not very good, so we upgrade it to "fine mode" fax quality. It's really + // better and faster if the scanner produces TIFFs instead of PDFs. + $tmp0 = exec("convert -density 203x196 '$filepath' '$faxcache/deleteme.tif'", $tmp1, $tmp2); + if ($tmp2) die("convert returned $tmp2: $tmp0"); + $tmp0 = exec("cd '$faxcache'; tiffsplit 'deleteme.tif'; rm -f 'deleteme.tif'", $tmp1, $tmp2); + if ($tmp2) die("tiffsplit/rm returned $tmp2: $tmp0"); } else { - $tmp0 = exec("cd '$faxcache'; tiffsplit '$filepath'", $tmp1, $tmp2); - if ($tmp2) die("tiffsplit returned $tmp2: $tmp0"); + $tmp0 = exec("cd '$faxcache'; tiffsplit '$filepath'", $tmp1, $tmp2); + if ($tmp2) die("tiffsplit returned $tmp2: $tmp0"); } $tmp0 = exec("cd '$faxcache'; mogrify -resize 750x970 -format jpg *.tif", $tmp1, $tmp2); if ($tmp2) die("mogrify returned $tmp2: $tmp0; ext is '$ext'; filepath is '$filepath'"); - } +} - // Get the categories list. - $categories = array(); - getKittens(0, '', $categories); +// Get the categories list. +$categories = array(); +getKittens(0, '', $categories); - // Get the users list. - $ures = sqlStatement("SELECT username, fname, lname FROM users " . +// Get the users list. +$ures = sqlStatement("SELECT username, fname, lname FROM users " . "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) " . "ORDER BY lname, fname"); ?> - + <?php xl('Dispatch Received Document','e'); ?> @@ -322,6 +391,7 @@ div.section { + @@ -447,41 +536,73 @@ div.section { - - - +   + + + + +
+ + + + - - - - - - - - - - + + + + + + + + + +
+ -
- -
- ' - title='' - onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' /> - [?]' /> + +
+ +
+ ' + title='' + onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' /> + [?]' /> +
+
+ - @@ -507,12 +628,12 @@ div.section { @@ -587,31 +708,35 @@ div.section { ' />     ' onclick='window.close()' /> +    +' onclick='allCheckboxes(true)' /> +    +' onclick='allCheckboxes(false)' />


\n"; - echo " \n"; - echo " \n"; - echo " \n"; + ++$page; + $jfnamebase = $matches[1]; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; } - } - closedir($dh); +} +closedir($dh); ?>
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
$page\n"; - echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
$page\n"; + echo "
diff --git a/interface/fax/fax_dispatch_newpid.php b/interface/fax/fax_dispatch_newpid.php new file mode 100644 index 000000000..397ebea5b --- /dev/null +++ b/interface/fax/fax_dispatch_newpid.php @@ -0,0 +1,30 @@ + +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This is invoked via a jQuery getScript() from fax_dispatch.php. +// Its purpose is to return JavaScript that will set up patient- +// specific data when a patient is selected. Currently this data +// is just the caller's selection list of recent encounters. + +require_once("../globals.php"); +require_once("$srcdir/sql.inc"); + +$res = sqlStatement("SELECT date, encounter FROM form_encounter " . + "WHERE pid = '" . $_GET['p'] . "' " . + "ORDER BY date DESC, encounter DESC LIMIT 10"); + +echo "var s = document.forms[0].form_copy_sn_visit;\n"; +echo "s.options.length = 0;\n"; + +while ($row = sqlFetchArray($res)) { + echo "s.options[s.options.length] = new Option(" . + "'" . substr($row['date'], 0, 10) . "', " . + "'" . $row['encounter'] . "'" . + ");\n"; +} +?> \ No newline at end of file -- 2.11.4.GIT