From 1dc940d59c66e233a8f8f48486cf82f7daf938c4 Mon Sep 17 00:00:00 2001 From: Paul Simon Date: Wed, 24 Nov 2010 15:50:25 +0530 Subject: [PATCH] When it is typed speedily in the ajax,at some cases the result was not as expected. This usually happens when the result set is huge.It is corrected. The ajax when patient name was typed, now picks only from the starting of the first,middle or last names. When multiple encounters are there the issue that the non payed one getting pushed to the next level is avoided. Ajax code for patient search only with non submission is added. Signed-off-by: Paul Simon --- library/ajax/payment_ajax.php | 21 ++++-- library/ajax/payment_ajax_jav.inc.php | 117 +++++++++++++++++++++++++++++++--- library/payment.inc.php | 63 ++++++++++-------- 3 files changed, 161 insertions(+), 40 deletions(-) diff --git a/library/ajax/payment_ajax.php b/library/ajax/payment_ajax.php index bf87f5cec..85c84335a 100644 --- a/library/ajax/payment_ajax.php +++ b/library/ajax/payment_ajax.php @@ -83,7 +83,7 @@ function AjaxDropDownCode() "; } $StringForAjax.=""; - echo $StringForAjax; + echo strlen($_REQUEST['insurance_text_ajax']).'~`~`'.$StringForAjax; die; } //=============================================================================== @@ -96,14 +96,24 @@ function AjaxDropDownCode() if(isset($_REQUEST['patient_code']) && $_REQUEST['patient_code']!='') { $patient_code=formData('patient_code','',true); - $StringToAppend="PutTheValuesClickDistribute"; - $StringToAppend2="PlaceValuesDistribute"; + if(isset($_REQUEST['submit_or_simple_type']) && $_REQUEST['submit_or_simple_type']=='Simple') + { + $StringToAppend="PutTheValuesClickPatient"; + $StringToAppend2="PlaceValuesPatient"; + } + else + { + $StringToAppend="PutTheValuesClickDistribute"; + $StringToAppend2="PlaceValuesDistribute"; + } + $patient_code_complete=$_REQUEST['patient_code'];//we need the spaces here } elseif(isset($_REQUEST['insurance_text_ajax']) && $_REQUEST['insurance_text_ajax']!='') { $patient_code=formData('insurance_text_ajax','',true); $StringToAppend="PutTheValuesClick"; $StringToAppend2="PlaceValues"; + $patient_code_complete=$_REQUEST['insurance_text_ajax'];//we need the spaces here } $CountIndex=1; $StringForAjax="
@@ -122,7 +132,8 @@ function AjaxDropDownCode() "; $res = sqlStatement("SELECT pid as id,fname,lname,mname,DOB FROM patient_data - where INSTR('$patient_code', fname) or INSTR('$patient_code', lname) or fname like '$patient_code%' or lname like '$patient_code%' or pid like '$patient_code%' ORDER BY lname"); + where fname like '$patient_code%' or lname like '$patient_code%' or mname like '$patient_code%' or + CONCAT(lname,' ',fname,' ',mname) like '$patient_code%' or pid like '$patient_code%' ORDER BY lname"); while ($row = sqlFetchArray($res)) { if($CountIndex%2==1) @@ -150,7 +161,7 @@ function AjaxDropDownCode() "; } $StringForAjax.="
"; - echo $StringForAjax; + echo strlen($patient_code_complete).'~`~`'.$StringForAjax; die; } //=============================================================================== diff --git a/library/ajax/payment_ajax_jav.inc.php b/library/ajax/payment_ajax_jav.inc.php index 8d12af393..b46ed4f1b 100644 --- a/library/ajax/payment_ajax_jav.inc.php +++ b/library/ajax/payment_ajax_jav.inc.php @@ -37,7 +37,7 @@ $(document).ready(function(){ } else {//Both insurance or patient can come.The drop down value in 'type_name' decides which one to process. - ajaxFunction('non'); + ajaxFunction('non','Simple',document.getElementById('type_code')); return; } }); @@ -48,18 +48,40 @@ $(document).ready(function(){ } else { - ajaxFunction('patient'); + ajaxFunction('patient','Submit',document.getElementById('patient_code')); return; } }); - function ajaxFunction(Source) { + $("#form_pt_name").keyup(function(e){ + if (e.which == 9 || e.which == 13) + {//tab key,enter key.Prevent ajax activity. + return false; + } + else + { + ajaxFunction('patient','Simple',document.getElementById('form_pt_name')); + return; + } + }); + $("#encounter_no").keyup(function(e){ + if (e.which == 9 || e.which == 13) + {//tab key,enter key.Prevent ajax activity. + return false; + } + else + { + ajaxFunction('encounter'); + return; + } + }); + function ajaxFunction(Source,SubmitOrSimple,SourceObject) { if(Source=='encounter') { document.getElementById('ajax_mode').value='encounter'; } else if(Source=='patient') { - if(document.getElementById('patient_code').value.length<3) + if(SourceObject.value.length<3) return false; document.getElementById('ajax_mode').value='set_patient'; } @@ -83,14 +105,43 @@ $(document).ready(function(){ dataType: "html", data: { ajax_mode: document.getElementById('ajax_mode').value, - patient_code: Source=='patient' ? document.getElementById('patient_code').value : '', + patient_code: Source=='patient' ? SourceObject.value : '', insurance_text_ajax: document.getElementById('type_code') ? document.getElementById('type_code').value : '', - encounter_patient_code:Source=='encounter' ? document.getElementById('hidden_patient_code').value : '' + encounter_patient_code:Source=='encounter' ? document.getElementById('hidden_patient_code').value : '', + submit_or_simple_type:SubmitOrSimple }, - success: function(thedata){//alert(thedata) + //async: false, + success: function(thedata){ + if(Source=='encounter') + { + ; + } + else + { + ThedataArray=thedata.split('~`~`'); + thedata=ThedataArray[1]; + if(Source=='patient') + { + if(ThedataArray[0]!=SourceObject.value.length) + { + return;//To deal with speedy typing. + } + } + else + { + if(ThedataArray[0]!=document.getElementById('type_code').value.length) + { + return;//To deal with speedy typing. + } + } + } document.getElementById('ajax_mode').value=''; if(Source=='encounter') { + if(document.getElementById('SelFacility')) + { + document.getElementById('SelFacility').style.display='none';//In Internet explorer this drop down comes over the ajax listing. + } $("#ajax_div_encounter_error").empty(); $("#ajax_div_encounter").empty(); $("#ajax_div_encounter").html(thedata); @@ -98,6 +149,10 @@ $(document).ready(function(){ } else if(Source=='patient') { + if(document.getElementById('SelFacility')) + { + document.getElementById('SelFacility').style.display='none';//In Internet explorer this drop down comes over the ajax listing. + } $("#ajax_div_patient_error").empty(); $("#ajax_div_patient").empty(); $("#ajax_div_insurance_error").empty(); @@ -139,10 +194,18 @@ function PutTheValuesClick(Code,Name) document.getElementById('hidden_type_code').value=Code; document.getElementById('div_insurance_or_patient').innerHTML=Code; document.getElementById('ajax_div_insurance').style.display='none'; + $("#ajax_div_patient_error").empty(); + $("#ajax_div_patient").empty(); + $("#ajax_div_insurance_error").empty(); + $("#ajax_div_insurance").empty(); document.getElementById('type_code').focus(); } function PutTheValuesClickDistribute(Code,Name) {//Used while -->CLICK<-- over list in the patient portion before the start of distribution of amount. + if(document.getElementById('SelFacility')) + { + document.getElementById('SelFacility').style.display='';//In Internet explorer this drop down comes over the ajax listing. + } document.getElementById('patient_code').value=Name; document.getElementById('hidden_ajax_patient_close_value').value=Name; document.getElementById('hidden_patient_code').value=Code; @@ -153,8 +216,21 @@ function PutTheValuesClickDistribute(Code,Name) top.restoreSession(); document.forms[0].submit(); } +function PutTheValuesClickPatient(Code,Name)//Non submission patient ajax. + { + document.getElementById('form_pt_name').value=Name; + document.getElementById('hidden_ajax_patient_close_value').value=Name; + document.getElementById('hidden_patient_code').value=Code; + document.getElementById('ajax_div_patient').style.display='none'; + document.getElementById('form_pt_code').innerHTML=Code; + document.getElementById('form_pt_name').focus(); + } function PutTheValuesClickEncounter(Code,Name) {//Used while -->CLICK<-- over list in the encounter portion. + if(document.getElementById('SelFacility')) + { + document.getElementById('SelFacility').style.display='';//In Internet explorer this drop down comes over the ajax listing. + } document.getElementById('encounter_no').value=Code; document.getElementById('hidden_ajax_encounter_close_value').value=Code; document.getElementById('hidden_encounter_no').value=Code; @@ -193,6 +269,20 @@ function PlaceValuesDistribute(evt,Code,Name) document.getElementById('patient_code').focus(); } } +function PlaceValuesPatient(evt,Code,Name) + { + evt = (evt) ? evt : window.event; + var charCode = (evt.which) ? evt.which : evt.keyCode; + if (charCode == 13)//enter key + {//Vanish the list and populate the parent text box + PutTheValuesClickPatient(Code,Name); + PreventIt(evt) //For browser chorome.It gets submitted,to prevent it the PreventIt(evt) is written + } + else if(!((charCode == 38) || (charCode == 40))) + {//if non arrow keys, focus on the parent text box(ie he again types and wants ajax to activate) + document.getElementById('form_pt_name').focus(); + } + } function PlaceValuesEncounter(evt,Code,Name) {//Used while -->KEY PRESS<-- over list in the encounter portion. evt = (evt) ? evt : window.event; @@ -266,7 +356,14 @@ function HideTheAjaxDivs() { if(document.getElementById('ajax_div_patient').style.display!='none') { - document.getElementById('patient_code').value=document.getElementById('hidden_ajax_patient_close_value').value; + if(document.getElementById('SelFacility')) + { + document.getElementById('SelFacility').style.display='';//In Internet explorer this drop down comes over the ajax listing. + } + if(document.getElementById('patient_code')) + document.getElementById('patient_code').value=document.getElementById('hidden_ajax_patient_close_value').value; + else if(document.getElementById('form_pt_name')) + document.getElementById('form_pt_name').value=document.getElementById('hidden_ajax_patient_close_value').value; $("#ajax_div_patient_error").empty(); $("#ajax_div_patient").empty(); $("#ajax_div_insurance_error").empty(); @@ -278,6 +375,10 @@ function HideTheAjaxDivs() { if(document.getElementById('ajax_div_encounter').style.display!='none') { + if(document.getElementById('SelFacility')) + { + document.getElementById('SelFacility').style.display='';//In Internet explorer this drop down comes over the ajax listing. + } document.getElementById('encounter_no').value=document.getElementById('hidden_ajax_encounter_close_value').value; $("#ajax_div_encounter_error").empty(); $("#ajax_div_encounter").empty(); diff --git a/library/payment.inc.php b/library/payment.inc.php index af566c350..770c9f28a 100644 --- a/library/payment.inc.php +++ b/library/payment.inc.php @@ -31,33 +31,7 @@ function DistributionInsert($CountRow,$created_time,$user_id) {//Function inserts the distribution.Payment,Adjustment,Deductable,Takeback & Follow up reasons are inserted as seperate rows. //It automatically pushes to next insurance for billing. //In the screen a drop down of Ins1,Ins2,Ins3,Pat are given.The posting can be done for any level. - if(trim(formData('type_name' ))!='patient') - { - $ferow = sqlQuery("select last_level_closed from form_encounter where - pid ='".trim(formData('hidden_patient_code' ))."' and encounter='".trim(formData("HiddenEncounter$CountRow" ))."'"); - //multiple charges can come. - if($ferow['last_level_closed']0) - { - arSetupSecondary(trim(formData('hidden_patient_code' )), trim(formData("HiddenEncounter$CountRow" )),0); - } - //----------------------------------- - } - } + $Affected='no'; if (isset($_POST["Payment$CountRow"]) && $_POST["Payment$CountRow"]*1>0) { if(trim(formData('type_name' ))=='insurance') @@ -93,6 +67,7 @@ function DistributionInsert($CountRow,$created_time,$user_id) "', adj_amount = '" . 0 . "', account_code = '" . "$AccountCode" . "'"); + $Affected='yes'; } if (isset($_POST["AdjAmount$CountRow"]) && $_POST["AdjAmount$CountRow"]*1!=0) { @@ -123,6 +98,7 @@ function DistributionInsert($CountRow,$created_time,$user_id) "', memo = '" . "$AdjustString" . "', account_code = '" . "$AccountCode" . "'"); + $Affected='yes'; } if (isset($_POST["Deductible$CountRow"]) && $_POST["Deductible$CountRow"]*1>0) { @@ -141,6 +117,7 @@ function DistributionInsert($CountRow,$created_time,$user_id) "', memo = '" . "Deductable $".trim(formData("Deductible$CountRow" )) . "', account_code = '" . "Deduct" . "'"); + $Affected='yes'; } if (isset($_POST["Takeback$CountRow"]) && $_POST["Takeback$CountRow"]*1>0) { @@ -158,6 +135,7 @@ function DistributionInsert($CountRow,$created_time,$user_id) "', adj_amount = '" . 0 . "', account_code = '" . "Takeback" . "'"); + $Affected='yes'; } if (isset($_POST["FollowUp$CountRow"]) && $_POST["FollowUp$CountRow"]=='y') { @@ -176,6 +154,37 @@ function DistributionInsert($CountRow,$created_time,$user_id) "', follow_up = '" . "y" . "', follow_up_note = '" . trim(formData("FollowUpReason$CountRow" )) . "'"); + $Affected='yes'; + } + if($Affected=='yes') + { + if(trim(formData('type_name' ))!='patient') + { + $ferow = sqlQuery("select last_level_closed from form_encounter where + pid ='".trim(formData('hidden_patient_code' ))."' and encounter='".trim(formData("HiddenEncounter$CountRow" ))."'"); + //multiple charges can come. + if($ferow['last_level_closed']0) + { + arSetupSecondary(trim(formData('hidden_patient_code' )), trim(formData("HiddenEncounter$CountRow" )),0); + } + //----------------------------------- + } + } } } //=============================================================================== -- 2.11.4.GIT