r6166 - in branches/bmas-staging: data/schema/mysql lib/org/freemedsoftware/module

Showing 1-1 of 1 messages
r6166 - in branches/bmas-staging: data/schema/mysql lib/org/freemedsoftware/module subve...@svn.freemedsoftware.org 10/25/11 11:41 AM
Author: jeff
Date: 2011-10-25 14:41:56 -0400 (Tue, 25 Oct 2011)
New Revision: 6166

Modified:
   branches/bmas-staging/data/schema/mysql/photoid.sql
   branches/bmas-staging/lib/org/freemedsoftware/module/PhotographicIdentification.class.php
Log:
Attempt to fix photo id lookup.


Modified: branches/bmas-staging/data/schema/mysql/photoid.sql
===================================================================
--- branches/bmas-staging/data/schema/mysql/photoid.sql        2011-10-25 00:34:25 UTC (rev 6165)
+++ branches/bmas-staging/data/schema/mysql/photoid.sql        2011-10-25 18:41:56 UTC (rev 6166)
@@ -91,7 +91,7 @@
 
 CREATE PROCEDURE photoid_GetLatest ( IN patient BIGINT(20) UNSIGNED )
 BEGIN
-        SELECT p_filename FROM photoid WHERE p_patient = patient ORDER BY p_stamp DESC LIMIT 1;
+        SELECT p_id FROM photoid WHERE p_patient = patient ORDER BY p_stamp DESC LIMIT 1;
 END;
 //
 

Modified: branches/bmas-staging/lib/org/freemedsoftware/module/PhotographicIdentification.class.php
===================================================================
--- branches/bmas-staging/lib/org/freemedsoftware/module/PhotographicIdentification.class.php        2011-10-25 00:34:25 UTC (rev 6165)
+++ branches/bmas-staging/lib/org/freemedsoftware/module/PhotographicIdentification.class.php        2011-10-25 18:41:56 UTC (rev 6166)
@@ -5,7 +5,7 @@
  //         Jeff Buchbinder <je...@freemedsoftware.org>
  //
  // FreeMED Electronic Medical Record and Practice Management System
- // Copyright (C) 1999-2010 FreeMED Software Foundation
+ // Copyright (C) 1999-2011 FreeMED Software Foundation
  //
  // 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
@@ -240,29 +240,32 @@
         public function GetPhotoID ( $patient, $force_id = false ) {
                 ob_start();
                 if ( ! $force_id ) {
-                        $pic = $GLOBALS['sql']->queryOneStoredProc( "CALL photoId_GetLatest ( ".( $patient+0 )." ) " );
+                        $id = (int) $GLOBALS['sql']->queryOneStoredProc( "CALL photoId_GetLatest ( ".( (int) $patient )." ) " );
                 } else {
-                        $pds = CreateObject( 'org.freemedsoftware.core.PatientDataStore' );
-                        $pic = $pds->ResolveFilename( $patient+0, get_class($this), $force_id+0 );
+                        $id = (int) $force_id;
                 }
-                if ( ! $pic ) { $pic = 'ui/dojo/htdocs/images/teak/noimage.250x250.png'; }
-                ob_end_clean();
-                ob_start();
-                readfile( $pic );
-                $x = ob_get_contents();
-                if ( strpos( $x, 'JFIF' ) > 0 ) {
+                $pds = CreateObject( 'org.freemedsoftware.core.PatientDataStore' );
+                $pic = $pds->GetFile( (int) $patient, get_class($this), $id );
+                if ( ! $pic ) {
+                        $x = 'ui/dojo/htdocs/images/teak/noimage.250x250.png';
+                        ob_end_clean();
+                        ob_start();
+                        readfile( $x );
+                        $pic = ob_get_contents();
+                        ob_end_clean();
+                }
+                if ( strpos( $pic, 'JFIF' ) > 0 ) {
                         Header( 'Content-type: image/jpeg' );
-                } else if ( strpos( $x, 'GIF89a' ) === 0 ) {
+                } else if ( strpos( $pic, 'GIF89a' ) === 0 ) {
                         Header( 'Content-type: image/gif' );
-                } else if ( strpos( $x, 'PNG' ) > 0 ) {
+                } else if ( strpos( $pic, 'PNG' ) > 0 ) {
                         Header( 'Content-type: image/png' );
                 }
                 Header( 'Pragma: no-cache' );
                 Header( 'Cache-Control: no-store, no-cache, must-revalidate' );
                 Header( 'Cache-Control: post-check=0, pre-check=0', false );
                 Header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
-                ob_end_clean();
-                print $x;
+                print $pic;
                 die();
         } // end method GetPhotoID