-
Notifications
You must be signed in to change notification settings - Fork 0
/
import-providence.php
380 lines (350 loc) · 11.3 KB
/
import-providence.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<?php //used to import Providence's feed....
require("globals.php5");
//define(HPP_ACCT,1);
define(HPP_ACCT,198); /********** UPDATE if acct was changed *******/
//define(HPP_UID,10001);
define(HPP_UID,10239); /********** UPDATE if master user was changed 19640*******/
require("cookies.php5");
require_once 'Classes/PHPExcel.php';
require_once 'Classes/PHPExcel/IOFactory.php';
error_reporting(E_ALL);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
if(isset($_POST["submit"]))
{
//print "trying to upload";
/*$fileName = basename($_FILES['uploadedfile']['name']);
$target_path = "tmp/";
$target_path .= $fileName;*/
//$filename="http://practicewithus.com/home/pwu-rssfeed.dot";
$filename="http://vendorsprd.providence.org/PhysicianOpportunityXmlProxy/niche.aspx";
//$filename="http://vendorsor.providence.org/PhysicianOpportunityXmlProxy/Niche.aspx";
$ch = curl_init($filename);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
if($output === false) throw new Exception('Curl error: ' . curl_error($ch),__LINE__);
curl_close($ch);
$xml = simplexml_load_string($output);//simplexml_load_string(str_replace('&','&',$output));
//if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path))
if($xml)
{
$hmacct = HPP_ACCT;
//get db stuff
$db = db_career();
$sql = "select sp_code,sp_name from specialties";
$res = $db->query($sql);
if( !$res ) throw new Exception(DEBUG?"$db->error : $sql":'Problem with Specialties Table',__LINE__);
$hamspec = array();
while( list($spc,$sph) = $res->fetch_row() ) { $hamspec[$sph] = $spc; }
$res->free();
$sql = "select st_code,st_name from states";
$res = $db->query($sql);
if( !$res ) throw new Exception(DEBUG?"$db->error : $sql":'Problem with States Table',__LINE__);
$hamstadt = array();
while( list($spc,$sph) = $res->fetch_row() ) { $hamstadt[$sph] = $spc; }
$res->free();
//$sql = "delete from opportunities where o_acct='".HPP_ACCT."' AND o_uid ='".HPP_UID."' ";
if(HPP_ACCT!=""){
$sql = "delete from opportunities where o_acct='".HPP_ACCT."' AND status=1 ";
$res = $db->query($sql);
}
//$sql = "delete from locations where l_acct='".HPP_ACCT."' AND l_uid ='".HPP_UID."' ";
//$res = $db->query($sql);
//$xml = simplexml_load_file($target_path);
/*foreach($xml->Opportunity as $job) {
echo $job->headline;
}*/
//echo var_dump($hamspec);
$client = new Customer($db,HPP_UID);
//chmod($target_path, 0644);
$states = array(
'Alabama'=>'AL',
'Alaska'=>'AK',
'Arizona'=>'AZ',
'Arkansas'=>'AR',
'California'=>'CA',
'Colorado'=>'CO',
'Connecticut'=>'CT',
'Delaware'=>'DE',
'Florida'=>'FL',
'Georgia'=>'GA',
'Hawaii'=>'HI',
'Idaho'=>'ID',
'Illinois'=>'IL',
'Indiana'=>'IN',
'Iowa'=>'IA',
'Kansas'=>'KS',
'Kentucky'=>'KY',
'Louisiana'=>'LA',
'Maine'=>'ME',
'Maryland'=>'MD',
'Massachusetts'=>'MA',
'Michigan'=>'MI',
'Minnesota'=>'MN',
'Mississippi'=>'MS',
'Missouri'=>'MO',
'Montana'=>'MT',
'Nebraska'=>'NE',
'Nevada'=>'NV',
'New Hampshire'=>'NH',
'New Jersey'=>'NJ',
'New Mexico'=>'NM',
'New York'=>'NY',
'North Carolina'=>'NC',
'North Dakota'=>'ND',
'Ohio'=>'OH',
'Oklahoma'=>'OK',
'Oregon'=>'OR',
'Pennsylvania'=>'PA',
'Rhode Island'=>'RI',
'South Carolina'=>'SC',
'South Dakota'=>'SD',
'Tennessee'=>'TN',
'Texas'=>'TX',
'Utah'=>'UT',
'Vermont'=>'VT',
'Virginia'=>'VA',
'Washington'=>'WA',
'West Virginia'=>'WV',
'Wisconsin'=>'WI',
'Wyoming'=>'WY'
);
$ar = array();
//echo $states["Washington"];
foreach($xml->Opportunity as $job) {
//echo $job->facility;
$jid = "JOB {" .addslashes($job->OpportunityId)."}";
$jobid = "(JOB ID " .addslashes($job->JobNumber).")";
$facility = addslashes($job->facility)." ".$jobid;
$city = $job->city;
$state = $states["$job->state"];
//$state = $job->state;
//echo $states["$job->state"];
$spec = addslashes(trim($job->specialty));
switch($spec)
{
case "Pediatric Neurology":
$spec="Child Neurology";
break;
case "Pulmonary Critical Care Medicine":
$spec="Pulmonary Critical Care";
break;
case "Pulmonology":
$spec="Pulmonary Disease";
break;
case "Surgery - Cardiothoracic":
$spec="Surgery - Cardiothoracic";
break;
case "Pulmonary Critical Care":
$spec="Pulmonary Critical Care Medicine";
break;
case "Pediatric Dev/Behavioral Specialist":
$spec="Developmental-Behavioral Pediatrics";
break;
case "Family Medicine":
$spec="Family Practice";
break;
case "Hospice & Palliative Medicine":
$spec="Hospice and Palliative Medicine";
break;
case "Pediatric":
$spec="Pediatrics";
break;
case "Immediate Care":
$spec="Urgent Care Medicine";
break;
case "Urgent Care":
$spec="Urgent Care Medicine";
break;
case "Cardiology":
$spec="Cardiovascular Diseases";
break;
case "Orthopedics":
$spec="Orthopaedic Surgery";
break;
case "Geriatric Medicine":
$spec="Geriatric Medicine - IM";
break;
case "Hyperbaric Medicine":
$spec="Undersea and Hyperbaric Medicine";
break;
case "Pediatric Hematology-Oncology":
$spec="Pediatric Hematology/Oncology";
break;
case "Perinatology":
$spec="Maternal and Fetal Medicine";
break;
case "Genetics":
$spec="Medical Genetics";
break;
case "Psychiatry - Child and Adolescent":
$spec="Child and Adolescent Psychiatry";
break;
case "Executive - Physician":
$spec="Administration";
break;
case "Pain Management and Rehabilitative":
$spec="Physical Medicine and Rehab - Interventional Pain Management";
break;
case "Physiatry":
$spec="Physical Medicine and Rehabilitation";
break;
case "Obstetrics/Gynecology":
$spec="Obstetrics and Gynecology";
break;
case "Neonatology":
$spec="Neonatal-Perinatal Medicine";
break;
case "Cardiothoracic Surgery":
$spec="Surgery - Cardiothoracic";
break;
case "Cardiovascular Surgery":
$spec="Surgery - Cardiothoracic";
break;
/*case "Urogynecology":
$spec="Urogynecology";
break;*/
case "Thoracic Surgery":
$spec="Thoracic and Cardiac Surgery";
break;
case "Pulmonary/Critical Care/Intensivist":
$spec="Pulmonary Critical Care";
break;
case "Academic":
$spec="Academic";
break;
case "Surgery Specialties":
$spec="General Surgery";
break;
case "Sports":
$spec="Orthopedic Surgery – Sports Medicine";
break;
case "Cardiac Surgery":
$spec="Surgery - Cardiothoracic";
break;
case "Pediatric - General":
$spec="Pediatrics";
break;
case "Urgent Care":
$spec="Urgent Care Medicine";
break;
case "Urgent Care – UCM":
$spec="Urgent Care Medicine";
break;
case "Pediatric Hematology Oncology":
$spec="Pediatric Hematology/Oncology";
break;
case "Surgery - cardiothoracic":
$spec="Surgery - Cardiothoracic";
break;
case "Urogynecology":
$spec="Urological Gynecology";
break;
case "Maternal Fetal Medicine":
$spec="Maternal and Fetal Medicine";
break;
case "Sports Medicine":
$spec="Sports Medicine - FP";
break;
case "PMR interventional pain management":
$spec="Physical Medicine and Rehab - Interventional Pain Management";
break;
case "Maternal-Fetal Medicine":
$spec="Maternal and Fetal Medicine";
break;
case "Gynecology-Oncology":
$spec="Gynecologic Oncology";
break;
case "Pulmonary Critical Care":
$spec="Pulmonary Critical Care Medicine";
break;
case "Critical Care":
$spec="Critical Care Medicine - IM";
break;
case "Neurology - MS":
$spec="Neurology - Multiple Sclerosis";
break;
case "Pediatrics – General":
$spec="Pediatrics";
break;
case "Palliative Care":
$spec="Palliative Medicine";
break;
case "Pulmonary Disease – Critical Care":
$spec="Pulmonary Critical Care Medicine";
break;
case "Pediatrics – General":
$spec="Pediatrics";
break;
case "Pediatrics - General":
$spec="Pediatrics";
break;
}
$spec = trim($spec);
try{
@$spec2 = $spec == 'Emergency Medicine'?'EM':($spec == 'Hospitalist Medicine'?'HOS':$hamspec["$spec"]);
//echo $spec2.EOL;
}catch(Exception $e){
echo $e->getMessage().' ('.$e->getCode().')<br>';
}
if(!$spec2){
echo "No specialty mapping for ".$spec.". Will be skipped.<br/>";
}
else
{
$title=$job->headline;
if($title==''||$title==null)
$title = $spec2." at ".$facility;
//$title .= " ".$jobid;
$description = html_entity_decode(addslashes($job->description));
//$link = $job->entityWebaddress; //hard-coded
$contact = $job->recruiter_name;
$phone = $job->RecruiterPhone;
//$phone='';
$email = $job->recruiter_email;
$ldescr = html_entity_decode(addslashes($job->facil_description));//$job->facil_description."<br/>"; //html_entity_decode($job->facil_description,ENT_QUOTES,"ISO-8859-1"); //html_entity_decode(($job->facil_description));
//echo $ldescr;
//enter database
$acity = addslashes($city); $astate = addslashes($state);
$sql = "select l_id from locations where l_acct = $client->acct and status = 1 and l_facility = '$facility' and l_city = '$acity' and l_state = '$astate'";
$res = $db->query($sql);
if( !$res ) throw new Exception(DEBUG?"$db->error : $sql":'Problem with Locations Table',__LINE__);
if( !$res->num_rows ) { // create new location
//$ldescr = addslashes($link);
$cdescr = html_entity_decode(addslashes($job->city_description));
$sql ="insert into locations (l_facility,l_city,l_state,l_uid,l_acct,l_description,l_commdescr,exp_date) values('$facility','$acity','$astate',$client->uid,$client->acct,'$ldescr','$cdescr',ADDDATE(NOW(), INTERVAL 1 YEAR))";
$result = $db->query($sql);
if( !$result ) throw new Exception(DEBUG?"$db->error: $sql":'Can not insert locations',__LINE__);
$locid = $db->insert_id;
}
else list($locid) = $res->fetch_row();
$res->free();
//create opp
@$opp = new Opportunity($db,0,$locid,$client->uid,$client->acct);
$opp->o_name = $jid;
$opp->o_city = ($acity);
$opp->o_state = ($astate);
$opp->specialty = $spec2;
$opp->o_facility = $facility; //strip_tags($facility) ;
$opp->description = $description;
$opp->exp_date = $client->exp_date;
$opp->practice_type = $spec2 == 'HOS'?'Hosp':($spec == 'EM'?'ER':'');
//if(stripos('Part-Time',$jde->status) !== false ) $opp->practice_type .= ($opp->practice_type?',':'').'Locum';
//$jco = $job->jobContact;
$opp->o_email = addslashes($email);
$opp->o_phone = addslashes($phone);
$opp->o_contact = addslashes(htmlspecialchars( strip_tags($contact)));
//$progress .= ' creating...';
@$opp->save();
$sql = "insert into importrac (jobid,jobacct,jobflag,jobopp) VALUES ('$jid',$client->acct,0,$opp->id) ON DUPLICATE KEY UPDATE jobflag=0";
$db->query($sql);
}
}
print "jobs added!";
}
}
?>
<h1>Providence Import</h1>
<form action="import-providence.php" method="post" enctype="multipart/form-data">
<input type="submit" name="submit" value="Run">
</form>