INSERT INTO #Request.prefix_db_lookup#.Employee (EmployeeType,Agency_ID,Last_name,First_Name,Address1,Address2,City,State,Zip,Home_Phone,Cell_Phone,Beeper,Email,status, Record_creation_Date, Record_created_By, Record_Mod_Date, Record_Mod_By,Latitude,Longitude) VALUES ('Physician',#session.agencyid#,'#form.lastname#','#form.firstname#','#form.address1#','#form.address2#','#form.city#', '#form.state#','#form.zip#','#form.telephone1#','#form.cell#','#form.beeper#','#form.email#','#form.status#', #now()#, #Session.EmployeeID#, #now()#, #Session.EmployeeID#,0,0) SELECT MAX(Employee_ID) as maxid from #Request.prefix_db_lookup#.Employee INSERT INTO #Request.prefix_db_lookup#.Physician (Employee_ID,Agency_ID,telephone2,natl_provider_id,fax) VALUES (#newvisit.maxid#,#session.agencyid#,'#form.telephone2#','#form.natl_provider_id#','#form.fax#') Select Max(Physician_ID) as PhysID from #Request.prefix_db_lookup#.Physician Insert into #Request.prefix_db_lookup#.patientphysician(Patient_ID,Physician_ID)values(#session.cs.patientid#,#PhysicianID#) Update #Request.prefix_db_lookup#.Employee set Last_name='#form.lastname#', First_Name='#form.firstname#', Address1='#form.address1#', Address2='#form.address2#', City='#form.city#', State='#form.state#', Zip='#form.zip#', Home_Phone='#form.telephone1#', Cell_Phone='#form.cell#', Beeper='#form.beeper#', Email='#form.email#', status='#form.status#', Record_Mod_Date=#now()#, Record_Mod_By=#Session.EmployeeID# WHERE Employee_ID = #form.Employee_ID# Update #Request.prefix_db_lookup#.Physician set telephone2='#form.telephone2#', fax='#form.fax#', natl_provider_id='#form.natl_provider_id#' WHERE Physician_ID = #form.Physician_ID#