Visolve: Clear Active Patient Changes
authorroot <visolve.openemr@gmail.com>
Thu, 27 Dec 2012 04:38:23 +0000 (27 10:08 +0530)
committerbradymiller <bradymiller@users.sourceforge.net>
Fri, 28 Dec 2012 02:55:17 +0000 (27 18:55 -0800)
interface/main/left_nav.php
interface/main/main_title.php
library/ajax/unset_session_ajax.php [new file with mode: 0644]

index 0c1be19..8703d08 100644 (file)
@@ -551,6 +551,23 @@ function goHome() {
     top.frames['RBot'].location='messages/messages.php?form_active=1';
 }
 
+//Function to clear active patient and encounter in the server side
+function clearactive() {
+       top.restoreSession();
+       //Ajax call to clear active patient in session
+       $.ajax({
+         type: "POST",
+         url: "<?php echo $GLOBALS['webroot'] ?>/library/ajax/unset_session_ajax.php",
+         data: { func: "unset_pid"},
+         success:function( msg ) {
+               clearPatient();
+               top.frames['RTop'].location='<?php echo $GLOBALS['default_top_pane']?>';
+               top.frames['RBot'].location='messages/messages.php?form_active=1';
+         }
+       });
+    
+       $(parent.Title.document.getElementById('clear_active')).hide();
+}
  // Reference to the search.php window.
  var my_window;
 
@@ -713,6 +730,7 @@ function goHome() {
   }
 
   reloadIssues(pid);
+  $(parent.Title.document.getElementById('clear_active')).show();//To display Clear Active Patient button on selecting a patient
  }
  function setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray) {
  //This function lists all encounters of the patient.
@@ -790,9 +808,9 @@ function getEncounterTargetFrame( name ) {
   active_pid = 0;
   active_encounter = 0;
   setDivContent('current_patient', '<b><?php xl('None','e'); ?></b>');
-  setTitleContent('current_patient', '<b><?php xl('None','e'); ?></b>');
+  $(parent.Title.document.getElementById('current_patient_block')).hide();
   top.window.parent.Title.document.getElementById('past_encounter').innerHTML='';
-  top.window.parent.Title.document.getElementById('current_encounter').innerHTML="<b><?php echo htmlspecialchars( xl('None'), ENT_QUOTES) ?></b>";
+  $(parent.Title.document.getElementById('current_encounter_block')).hide();
   reloadPatient('');
   syncRadios();
  }
index 71eeddd..b5d71b4 100644 (file)
@@ -79,6 +79,9 @@ $res = sqlQuery("select * from users where username='".$_SESSION{"authUser"}."'"
 <tr><td style="vertical-align:text-bottom;">
                <a href='' class="css_button_small" style="margin:0px;vertical-align:top;" id='new0' onClick=" return top.window.parent.left_nav.loadFrame2('new0','RTop','new/new.php')">
                <span><?php echo htmlspecialchars( xl('NEW PATIENT'), ENT_QUOTES); ?></span></a>
+               &nbsp;
+               <a href='' class="css_button_small" style="margin:0px;vertical-align:top;display:none;" id='clear_active' onClick="javascript:parent.left_nav.clearactive();return false;">
+               <span><?php echo htmlspecialchars( xl('CLEAR ACTIVE PATIENT'), ENT_QUOTES); ?></span></a>
        </td></tr>
 <?php } //end of acl_check('patients','demo','',array('write','addonly') if ?>
 
diff --git a/library/ajax/unset_session_ajax.php b/library/ajax/unset_session_ajax.php
new file mode 100644 (file)
index 0000000..8b3a8a1
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+ /**
+ * library/ajax/unset_session_ajax.php Clear active patient on the server side.
+ *
+ * Copyright (C) 2012 Visolve <services@visolve.com>
+ *
+ * LICENSE: 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 3
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
+ *
+ * @package OpenEMR
+ * @author  Visolve <services@visolve.com>
+ * @link    http://www.open-emr.org
+ */
+$fake_register_globals=false;
+$sanitize_all_escapes=true;
+
+require_once("../../interface/globals.php");
+require_once("../pid.inc");
+
+//Setpid function is called on receiving an ajax request.
+if(($_POST['func']=="unset_pid"))
+{
+       setpid(0);
+}
+?>