From ede515225b2266cdaa02a7e095b0667ab78cdb55 Mon Sep 17 00:00:00 2001 From: tmccormi Date: Wed, 29 Dec 2010 00:41:33 -0800 Subject: [PATCH] Enhance Photo and Patient ID card handling with a widget that supports thumnails that can be clicked to show full size, uses controller.php for secure access. Adds a Patient Photograph document category --- interface/patient_file/summary/demographics.php | 157 ++++++++++++++++-------- library/globals.inc.php | 9 +- sql/3_2_0-to-4_0_0_upgrade.sql | 6 + sql/database.sql | 15 +-- version.php | 2 +- 5 files changed, 130 insertions(+), 59 deletions(-) diff --git a/interface/patient_file/summary/demographics.php b/interface/patient_file/summary/demographics.php index 0edf8585c..ed60ae26d 100644 --- a/interface/patient_file/summary/demographics.php +++ b/interface/patient_file/summary/demographics.php @@ -18,7 +18,6 @@ $fake_register_globals=false; 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"); @@ -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 = "" . + " $doc_catg:$image_file" . + htmlspecialchars(" $doc_catg: $image_file") . + "

"; + } + else { + $to_url = "" . + "" . + htmlspecialchars( xl("View"), ENT_QUOTES )."  " . + htmlspecialchars( "$doc_catg - $image_file", ENT_QUOTES ) . + "

"; + } + echo $to_url; +} + ?> @@ -58,7 +121,7 @@ function print_as_money($money) { -