Skip to content

Commit

Permalink
Enhance Photo and Patient ID card handling with a widget that support…
Browse files Browse the repository at this point in the history
…s thumnails that can be clicked to show full size, uses controller.php for secure access. Adds a Patient Photograph document category
  • Loading branch information
tmccormi committed Dec 29, 2010
1 parent f3ebbb3 commit ede5152
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 59 deletions.
157 changes: 107 additions & 50 deletions interface/patient_file/summary/demographics.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
require_once("$srcdir/classes/Address.class.php");
require_once("$srcdir/classes/InsuranceCompany.class.php");
require_once("$srcdir/classes/Document.class.php");
require_once("./patient_picture.php");
require_once("$srcdir/options.inc.php");
require_once("../history/history.inc.php");
require_once("$srcdir/formatting.inc.php");
Expand All @@ -42,6 +41,70 @@ function print_as_money($money) {
return "$ " . strrev($tmp);
}
}

// get an array from Photos category
function pic_array($pid,$picture_directory) {
$pics = array();
$sql_query = "select documents.id from documents join categories_to_documents " .
"on documents.id = categories_to_documents.document_id " .
"join categories on categories.id = categories_to_documents.category_id " .
"where categories.name like ? and documents.foreign_id = ?";
if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
while( $results = sqlFetchArray($query) ) {
array_push($pics,$results['id']);
}
}
return ($pics);
}
// Get the document ID of the first document in a specific catg.
function get_document_by_catg($pid,$doc_catg) {

$result = array();

if ($pid and $doc_catg) {
$result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
"documents AS d, categories_to_documents AS cd, categories AS c " .
"WHERE d.foreign_id = ? " .
"AND cd.document_id = d.id " .
"AND c.id = cd.category_id " .
"AND c.name LIKE ? " .
"ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg) );
}

return($result['id']);
}

// Display image in 'widget style'
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" . // Force image type inot 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' 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;
}

?>
<html>

Expand All @@ -58,7 +121,7 @@ function print_as_money($money) {
<script type="text/javascript" src="../../../library/js/jquery.1.3.2.js"></script>
<script type="text/javascript" src="../../../library/js/common.js"></script>
<script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
<script language="JavaScript">
<script type="text/javascript" language="JavaScript">
//Visolve - sync the radio buttons - Start
if((top.window.parent) && (parent.window)){
var wname = top.window.parent.left_nav;
Expand Down Expand Up @@ -177,33 +240,25 @@ function toggleIndicator(target,div) {

tabbify();

// special size for
// modal for dialog boxes
$(".large_modal").fancybox( {
'overlayOpacity' : 0.0,
'showCloseButton' : true,
'frameHeight' : 600,
'frameWidth' : 1000,
'centerOnScroll' : false
});

// special size for
$(".medium_modal").fancybox( {
'overlayOpacity' : 0.0,
'showCloseButton' : true,
'frameHeight' : 500,
'frameWidth' : 800,
'centerOnScroll' : false
'centerOnScroll' : false
});

// special size for
$("#image_view_modal").fancybox( {
// modal for image viewer
$(".image_modal").fancybox( {
'overlayOpacity' : 0.0,
'showCloseButton' : true,
'centerOnScroll' : false,
'autoScale' : true
'centerOnScroll' : false,
'autoscale' : true
});

});

</script>

<style type="css/text">
Expand Down Expand Up @@ -240,7 +295,6 @@ function toggleIndicator(target,div) {
}

if ($thisauth == 'write') {
foreach (pic_array() as $var) {print $var;}
echo "<table><tr><td><span class='title'>" .
htmlspecialchars(getPatientName($pid),ENT_NOQUOTES) .
"</span></td>";
Expand All @@ -255,17 +309,11 @@ function toggleIndicator(target,div) {
}

// Get the document ID of the patient ID card if access to it is wanted here.
$document_id = 0;
$idcard_doc_id = false;
if ($GLOBALS['patient_id_category_name']) {
$tmp = sqlQuery("SELECT d.id, d.date, d.url FROM " .
"documents AS d, categories_to_documents AS cd, categories AS c " .
"WHERE d.foreign_id = ? " .
"AND cd.document_id = d.id " .
"AND c.id = cd.category_id " .
"AND c.name LIKE ? " .
"ORDER BY d.date DESC LIMIT 1", array($pid, $GLOBALS['patient_id_category_name']) );
if ($tmp) $document_id = $tmp['id'];
$idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
}

?>
<table cellspacing='0' cellpadding='0' border='0'>
<tr>
Expand Down Expand Up @@ -589,7 +637,7 @@ function toggleIndicator(target,div) {
$fixedWidth = true;
expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?>
<br/>
<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
<div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
</div>
</td>
</tr>
Expand Down Expand Up @@ -650,30 +698,39 @@ function toggleIndicator(target,div) {
<table>
<tr>
<td>
<div>
<?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()' class='css_button_small'>" .
"<span>" .
htmlspecialchars( xl("View"), ENT_QUOTES )."</a> &nbsp;" . htmlspecialchars( xl("PDF of Patient ID Card"), ENT_QUOTES ) .
"</span> <br /><hr>";
} 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='css_button_small' id='image_view_modal'>" .
"<span>" .
htmlspecialchars( xl("View"), ENT_QUOTES )."</a> &nbsp;" . htmlspecialchars( xl("Patient ID Card"), ENT_QUOTES ) .
"</span> <br /><hr>";
}
}

// If there is an ID Card or any Photos show the widget
$photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
if ($photos or $idcard_doc_id )
{
$widgetTitle = xl("ID Card") . '/' . xl("Photos");
$widgetLabel = "photos";
$linkMethod = "javascript";
$bodyClass = "notab";
$widgetAuth = false;
$fixedWidth = true;
expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel ,
$widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
$widgetAuth, $fixedWidth);
?>
<br />
<?php
if ($idcard_doc_id) {
image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
}

foreach ($photos as $photo_doc_id) {
image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
}
}
?>

<br />
</div>
<div>
<?php
// Advance Directives
if ($GLOBALS['advance_directives_warning']) {
// advance directives expand collapse widget
Expand Down
9 changes: 8 additions & 1 deletion library/globals.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,14 @@
xl('Patient ID Category Name'),
'text', // data type
'Patient ID card', // default
xl('Optional category name of a document to link to from the patient summary page. Lets you click on a patient name to see their ID card.')
xl('Optional category name for an ID Card image that can be viewed from the patient summary page.')
),

'patient_photo_category_name' => array(
xl('Patient Photo Category Name'),
'text', // data type
'Patient Photograph', // default
xl('Optional category name for photo images that can be viewed from the patient summary page.')
),

'MedicareReferrerIsRenderer' => array(
Expand Down
6 changes: 6 additions & 0 deletions sql/3_2_0-to-4_0_0_upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ ALTER TABlE patient_data
UPDATE categories_seq SET id = (select MAX(id) from categories);
#EndIf

#IfNotRow categories name Patient Photograph
INSERT INTO categories select (select MAX(id) from categories) + 1, 'Patient Photograph', '', 1, rght, rght + 1 from categories where name = 'Categories';
UPDATE categories SET rght = rght + 2 WHERE name = 'Categories';
UPDATE categories_seq SET id = (select MAX(id) from categories);
#Endif

#IfMissingColumn patient_data completed_ad
ALTER TABLE patient_data
ADD completed_ad VARCHAR(3) NOT NULL DEFAULT 'NO',
Expand Down
15 changes: 8 additions & 7 deletions sql/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,16 @@ CREATE TABLE `categories` (
-- Dumping data for table `categories`
--

INSERT INTO `categories` VALUES (1, 'Categories', '', 0, 0, 17);
INSERT INTO `categories` VALUES (1, 'Categories', '', 0, 0, 19);
INSERT INTO `categories` VALUES (2, 'Lab Report', '', 1, 1, 2);
INSERT INTO `categories` VALUES (3, 'Medical Record', '', 1, 3, 4);
INSERT INTO `categories` VALUES (4, 'Patient Information', '', 1, 5, 8);
INSERT INTO `categories` VALUES (4, 'Patient Information', '', 1, 5, 10);
INSERT INTO `categories` VALUES (5, 'Patient ID card', '', 4, 6, 7);
INSERT INTO `categories` VALUES (6, 'Advance Directive', '', 1, 9, 16);
INSERT INTO `categories` VALUES (7, 'Do Not Resuscitate Order', '', 6, 10, 11);
INSERT INTO `categories` VALUES (8, 'Durable Power of Attorney', '', 6, 12, 13);
INSERT INTO `categories` VALUES (9, 'Living Will', '', 6, 14, 15);
INSERT INTO `categories` VALUES (6, 'Advance Directive', '', 1, 11, 18);
INSERT INTO `categories` VALUES (7, 'Do Not Resuscitate Order', '', 6, 12, 13);
INSERT INTO `categories` VALUES (8, 'Durable Power of Attorney', '', 6, 14, 15);
INSERT INTO `categories` VALUES (9, 'Living Will', '', 6, 16, 17);
INSERT INTO `categories` VALUES (10, 'Patient Photograph', '', 4, 8, 9);

-- --------------------------------------------------------

Expand All @@ -139,7 +140,7 @@ CREATE TABLE `categories_seq` (
-- Dumping data for table `categories_seq`
--

INSERT INTO `categories_seq` VALUES (9);
INSERT INTO `categories_seq` VALUES (10);

-- --------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
// is a database change in the course of development. It is used
// internally to determine when a database upgrade is needed.
//
$v_database = 13;
$v_database = 14;
?>

0 comments on commit ede5152

Please sign in to comment.