/
customhotdoc.php
174 lines (152 loc) · 6.31 KB
/
customhotdoc.php
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<?php
require("globals.php5");
require("cookies.php5");
if( $UUID && $ACCESS && $ACCESS >= 200 ) try {
$db = db_clients();
if(isset($_POST["submitbtn"]))
{
//echo var_dump($_POST["spec"]);
foreach($_POST["spec"] as $k=>$v)
{
$specs[] = "'".$v."'";
}
$spec = implode(',',$specs);
//echo $spec;
$region="";
switch($_POST["pcregion"])
{
case "New England":
$region="'CT','ME','MA','NH','RI','VT'";
break;
case "Northeast":
$region="'NJ','NY','PA'";
break;
case "Midwest":
$region="'IL','IN','IA','KS','MO','NE','OH'";
break;
case "Upper Midwest":
$region="'MI','MN','ND','SD','WI'";
break;
case "Mid Atlantic":
$region="'DE','DC','MD','VA','WV'";
break;
case "South":
$region="'AL','AR','FL','GA','KY','LA','MS','NC','SC','TN'";
break;
case "Southwest":
$region="'AZ','NM','OK','TX'";
break;
case "Mountain":
$region="'CO','ID','MT','NV','UT','WY'";
break;
case "West/Pacific NW":
$region="'AK','CA','HI','OR','WA'";
break;
}
$sort=$_GET["sort"];
if($region!="")
{
if($sort=='')
{
$sql="SELECT ph_id, case when checkin=1 then fname else concat(left(fname,1),'.') end as fna, case when checkin=1 then lname else concat(left(lname,1),'.') end as lna, mddo, avail_date, spec, sp_name, pref_stopen, pref_states, pref_region, pref_commu2, as_new, last_save FROM physicians JOIN specialties ON spec = sp_code
WHERE inactive=0 AND pending=0 and status=1 and as_new != 2 and spec IN(".$spec.") and (pref_states IN(".$region.") OR ofstate IN(".$region.") OR state IN(".$region.") OR ofstate IN(".$region.") OR fel_state IN(".$region.") OR fel2_state IN(".$region.") OR res_state IN(".$region.") )
and (last_save BETWEEN date_sub(NOW(), interval 1 MONTH) AND NOW() OR reg_date BETWEEN date_sub(NOW(), interval 1 MONTH) AND NOW() OR date_mod BETWEEN date_sub(NOW(), interval 1 MONTH) AND NOW() )
ORDER BY date_mod desc"; //last mod - make last save sortable - add check for verified
}
else{
$sql="SELECT ph_id, case when checkin=1 then fname else concat(left(fname,1),'.') end as fna, case when checkin=1 then lname else concat(left(lname,1),'.') end as lna, mddo, avail_date, spec, sp_name, pref_stopen, pref_states, pref_region, pref_commu2, as_new, last_save FROM physicians JOIN specialties ON spec = sp_code
WHERE inactive=0 AND pending=0 and status=1 and as_new != 2 and spec IN(".$spec.") and (pref_states IN(".$region.") OR ofstate IN(".$region.") OR state IN(".$region.") OR ofstate IN(".$region.") OR fel_state IN(".$region.") OR fel2_state IN(".$region.") OR res_state IN(".$region.") )
and (last_save BETWEEN date_sub(NOW(), interval 1 MONTH) AND NOW() OR reg_date BETWEEN date_sub(NOW(), interval 1 MONTH) AND NOW() OR date_mod BETWEEN date_sub(NOW(), interval 1 MONTH) AND NOW() )
ORDER BY $sort desc";
//echo $sql;
}
//echo $sql;
$result = $db->query($sql);
if( !$result ) throw new Exception(DEBUG?"$db->error : $sql":'Can not execute query',__LINE__);
}
}
/*$db = db_clients();
$sql = "SELECT ph_id, case when checkin=1 then fname else concat(left(fname,1),'.') end as fna, case when checkin=1 then lname else concat(left(lname,1),'.') end as lna, mddo, avail_date, spec, sp_name, pref_stopen, pref_states, pref_region, pref_commu2, as_new, last_save FROM physicians JOIN specialties ON spec = sp_code WHERE last_save
BETWEEN curdate() AND date_add(curdate() , INTERVAL 1 day)
AND pending=0 AND physicians.status=1 and inactive=0 and as_new != 2
ORDER BY lname";*/
}
catch(Exception $e) {
$mesg = 'Attention: '.$e->getMessage().' ('.$e->getCode().')<br>';
//unset($oper);
}
$style = new OperPage('Custom Doc List',$UUID,'reports','customerstats');
$style->Output();
if( $UUID ) {
if( $ACCESS < 200 ) echo '<h1>Access Denied</h1>';
else {
?>
<h1>Custom Doc List </h1>
<p>Edit parameters below and submit to generate a list for clients.</p>
<?php
if( $mesg ) echo "<p id='error_msg'>$mesg</p>";
?>
<style>
.customtbl { width: 90%; }
.customtbl td { border: 1px solid; padding: 2px; }
</style>
<form action="" method="post">
<label><strong>Specialty</strong></label><br/>
<?php echo str_replace('name="spec"', 'name="spec" size="8" multiple', showSpecList($db,'', 'spec[]', 1)); ?>
<br/><br/>
<label><strong>Region</strong></label><br/>
<select style="vertical-align:top" id="pcregion" name="pcregion">
<option value="">--Select Region--</option>
<option value="New England">New England</option>
<option value="Northeast">Northeast</option>
<option value="Midwest">Midwest</option>
<option value="Upper Midwest">Upper Midwest</option>
<option value="Mid Atlantic">Mid Atlantic</option>
<option value="South">South</option>
<option value="Southwest">Southwest</option>
<option value="Mountain">Mountain</option>
<option value="West/Pacific NW">West/Pacific NW</option>
</select>
<br/><br/>
<input type="submit" value="Submit" name="submitbtn" />
</form>
<?php
$totals = $result->num_rows;
if($totals>0){
?>
<table class="customtbl">
<tr>
<th></th>
<th>ID</th>
<th>Name</th>
<th>Spec</th>
<th>Pref. States</th>
<th><a href="?sort=last_save">Last Save</a></th>
</tr>
<?php
}
for( $i=0; $i < $totals; $i++ ) {
$row = $result->fetch_object();
?>
<tr>
<td style="border: 1px solid; padding: 2px;" ><?php echo $i+1; ?></td>
<td style="border: 1px solid; padding: 2px;"><a href="http://physiciancareer.com/employers/showdoc/?lid=2&id=<?php echo $row->ph_id; ?>"><?php echo $row->ph_id; ?></a></td>
<td style="border: 1px solid; padding: 2px;"><?php echo $row->fna; ?> <?php echo $row->lna; ?></td>
<td style="border: 1px solid; padding: 2px;"><?php echo $row->spec." - ".$row->sp_name; ?></td>
<td style="border: 1px solid; padding: 2px;"><?php echo $row->pref_states; ?></td>
<td style="border: 1px solid; padding: 2px;"><?php echo $row->last_save; ?></td>
</tr>
<?php //echo $row->last_save; ?>
<?php
} // for (iteration)
if($totals>0){
?>
</table>
<?php
}
?>
<?php } // ACCESS
} // UUID
else showLoginForm();
$style->ShowFooter();
?>