Skip to content

Commit

Permalink
When it is typed speedily in the ajax,at some cases the result was no…
Browse files Browse the repository at this point in the history
…t 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 <paul@zhservices.com>
  • Loading branch information
Paul Simon authored and bradymiller committed Nov 24, 2010
1 parent b55cf2c commit 1dc940d
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 40 deletions.
21 changes: 16 additions & 5 deletions library/ajax/payment_ajax.php
Expand Up @@ -83,7 +83,7 @@ function AjaxDropDownCode()
</tr>";
}
$StringForAjax.="</table></div>";
echo $StringForAjax;
echo strlen($_REQUEST['insurance_text_ajax']).'~`~`'.$StringForAjax;
die;
}
//===============================================================================
Expand All @@ -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="<div id='AjaxContainerPatient'><table width='452' border='1' cellspacing='0' cellpadding='0'>
Expand All @@ -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)
Expand Down Expand Up @@ -150,7 +161,7 @@ function AjaxDropDownCode()
</tr>";
}
$StringForAjax.="</table></div>";
echo $StringForAjax;
echo strlen($patient_code_complete).'~`~`'.$StringForAjax;
die;
}
//===============================================================================
Expand Down
117 changes: 109 additions & 8 deletions library/ajax/payment_ajax_jav.inc.php
Expand Up @@ -37,7 +37,7 @@
}
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;
}
});
Expand All @@ -48,18 +48,40 @@
}
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';
}
Expand All @@ -83,21 +105,54 @@ function ajaxFunction(Source) {
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);
$("#ajax_div_encounter").show();
}
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();
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
63 changes: 36 additions & 27 deletions library/payment.inc.php
Expand Up @@ -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']<trim(formData("HiddenIns$CountRow" )))
{
sqlStatement("update form_encounter set last_level_closed='".trim(formData("HiddenIns$CountRow" ))."' where
pid ='".trim(formData('hidden_patient_code' ))."' and encounter='".trim(formData("HiddenEncounter$CountRow" ))."'");
//last_level_closed gets increased.
//-----------------------------------
// Determine the next insurance level to be billed.
$ferow = sqlQuery("SELECT date, last_level_closed " .
"FROM form_encounter WHERE " .
"pid = '".trim(formData('hidden_patient_code' ))."' AND encounter = '".trim(formData("HiddenEncounter$CountRow" ))."'");
$date_of_service = substr($ferow['date'], 0, 10);
$new_payer_type = 0 + $ferow['last_level_closed'];
if ($new_payer_type <= 3 && !empty($ferow['last_level_closed']) || $new_payer_type == 0)
++$new_payer_type;
$new_payer_id = arGetPayerID(trim(formData('hidden_patient_code' )), $date_of_service, $new_payer_type);
if($new_payer_id>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')
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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')
{
Expand All @@ -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']<trim(formData("HiddenIns$CountRow" )))
{
sqlStatement("update form_encounter set last_level_closed='".trim(formData("HiddenIns$CountRow" ))."' where
pid ='".trim(formData('hidden_patient_code' ))."' and encounter='".trim(formData("HiddenEncounter$CountRow" ))."'");
//last_level_closed gets increased.
//-----------------------------------
// Determine the next insurance level to be billed.
$ferow = sqlQuery("SELECT date, last_level_closed " .
"FROM form_encounter WHERE " .
"pid = '".trim(formData('hidden_patient_code' ))."' AND encounter = '".trim(formData("HiddenEncounter$CountRow" ))."'");
$date_of_service = substr($ferow['date'], 0, 10);
$new_payer_type = 0 + $ferow['last_level_closed'];
if ($new_payer_type <= 3 && !empty($ferow['last_level_closed']) || $new_payer_type == 0)
++$new_payer_type;
$new_payer_id = arGetPayerID(trim(formData('hidden_patient_code' )), $date_of_service, $new_payer_type);
if($new_payer_id>0)
{
arSetupSecondary(trim(formData('hidden_patient_code' )), trim(formData("HiddenEncounter$CountRow" )),0);
}
//-----------------------------------
}
}
}
}
//===============================================================================
Expand Down

0 comments on commit 1dc940d

Please sign in to comment.