-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.js
106 lines (89 loc) · 2.56 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
var xmlHttp;
$(document).ready(function() {
$("#submit_form").click(function(){
$("#loader").show();
$("#npi-error").html("");
$("#results").html("Loading...");
if($("#npi").val() == "" && $("#name").val() == "") {
$("#results").html("Search criteria is empty. Enter an NPI or a Name.");
} else {
if($("#name").val() != "") {
jLookUpViaName($("#name").val(), $("#type:checked").val(), $("#state:checked").val());
}
if(($("#npi").val().length > 0 && $("#npi").val().length < 10)
|| ($("#npi").val().length == 10 && !$.isNumeric($("#npi").val()))) {
$("#npi-error").html("NPI must be exactly 10 numeric characters");
$("#results").html("");
} else {
if($("#npi").val() != "") {
jLookUpViaNPI($("#npi").val());
}
}
}
$("#loader").hide();
});
$("#clear_form").click(function(){
$("#loader").hide();
$("#results").html("");
$("#npi-error").html("");
$("#npi").val("");
$("#name").val("");
});
});
function jLookUpViaName(name, type, location) {
xmlHttp=GetXmlHttpObject(xmlHttp);
if (xmlHttp==null)
{ alert ("Browser does not support this web page"); return; }
var nameArray = name.split(',');
var lastname="";
var firstname="";
if(type=='1')
{
lastname=nameArray[0];
if(nameArray.length>1)
{ firstname=nameArray[1]; }
}
$("#results").append("<br />Search via: "+name+', '+type+', '+location);
$("#results").append("<br />"+lastname+' + '+firstname);
var url="php/getProviderFromNPIViaName.php";
url=url+"?name="+name;
url=url+"&lastname="+lastname;
url=url+"&firstname="+firstname;
url=url+"&type="+type;
url=url+"&location="+location;
url=url+"&sid="+Math.random();
xmlHttp.open("GET",url,false);
xmlHttp.send(null);
$("#results").html(xmlHttp.responseText);
}
function jLookUpViaNPI(npi) {
$("#results").append("<br />Searching via NPI: "+npi);
xmlHttp=GetXmlHttpObject(xmlHttp);
if (xmlHttp==null)
{ alert ("Browser does not support this web page"); return; }
var url="php/getProviderFromNPIViaNPI.php";
url=url+"?NPI="+npi;
url=url+"&sid="+Math.random();
xmlHttp.open("GET",url,false);
xmlHttp.send(null);
$("#results").html(xmlHttp.responseText);
}
function GetXmlHttpObject(xmlHttp)
{
try
{ // Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{ //Internet Explorer
try
{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e)
{ try
{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
catch (failed)
{ alert("This version of Internet Explorer does not support xmlHttp. Try another browser"); }
}
}
return xmlHttp;
}