Assessment: #GetAssess.Assessment_Reason_M0100# Certification from: #DateFormat(GetAssess.Certification_Start, "mmm d, yyyy")# to #DateFormat(GetAssess.Certification_End, "mmm d, yyyy")# Payer: #TempPayer#
Notes
style="display:none" id="DateEmployee_#i# " >
Available Employee:
#DateFormat(x,'mm/dd/yyyy')#
SELECT case when Pt_Longitude is not null then Pt_Longitude else 0 end as LATITUDE,case when Pt_Longitude is not null then Pt_Longitude else 0 end as LONGITUDE,(SELECT DAYOFWEEK('#date1#')) as DAYOFDATE FROM #Request.prefix_db_agency#.pPatients WHERE PATIENT_ID='#Session.Patient.PatientIDValue#'
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID='#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i')) limit 1) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
(
(e.Loc_ID='#Session.AgencyID#')
and
( ( SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and Emp_ID=e.Emp_ID) >0)
AND status = 0
and (Emp_Type != 'Physician') )
and
(
( (select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#') < e.SundayMaxVisit) OR (SundayMaxVisit is null) OR (SundayMaxVisit='0')
)
order by PreferenceCount desc,Emp_Last asc
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID= '#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i')) limit 1) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
(
(Loc_ID ='#Session.AgencyID#')
and
(
(
SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and Emp_ID=e.Emp_ID
)
>0)
AND status = 0
AND (Emp_Type != 'Physician') )
and
(
((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#') < e.MondayMaxVisit)
OR (MondayMaxVisit is null)
OR (MondayMaxVisit='0')
)
order by PreferenceCount desc,Emp_Last asc
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID= '#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i')) limit 1) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
( (Loc_ID ='#Session.AgencyID#')
and
((SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and Emp_ID=e.Emp_ID )
>0)
AND status = 0
AND (Emp_Type != 'Physician')
)
and
(
((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#')< e.TuesdayMaxVisit )
OR (TuesdayMaxVisit is null)
OR (TuesdayMaxVisit='0')
)
order by PreferenceCount desc,Emp_Last asc
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID= '#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i')) limit 1 ) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
((Agency_Id='#Session.AgencyID#')
and
((
SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and Emp_ID=e.Emp_ID
)
>0)
AND status = 0
AND (Emp_Type != 'Physician') )
and
(
((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#') < e.WednesdayMaxVisit )
OR (WednesdayMaxVisit is null)
OR (WednesdayMaxVisit='0')
)
order by PreferenceCount desc,Emp_Last asc
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID= '#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i')) limit 1 ) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
(
(Loc_ID='#Session.AgencyID#')
and
(
(
SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and Emp_ID=e.Emp_ID
)
>0)
AND status = 0
AND (Emp_Type != 'Physician') )
and
(
((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#') < e.ThursdayMaxVisit )
OR (ThursdayMaxVisit is null)
OR (ThursdayMaxVisit='0')
)
order by PreferenceCount desc,Emp_Last asc
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID= '#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))limit 1 ) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
(
(Loc_ID='#Session.AgencyID#')
and
(
(
SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and Emp_ID=e.Emp_ID
)
>0)
AND status = 0
AND (Emp_Type != 'Physician') )
and
(
((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#') < e.FridayMaxVisit)
OR (FridayMaxVisit is null)
OR (FridayMaxVisit='0')
)
order by PreferenceCount desc,Emp_Last asc
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID= '#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))limit 1) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
( (Loc_ID='#Session.AgencyID#')
and
(
(
SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and Emp_ID=e.Emp_ID
)
>0)
AND status = 0
AND (Emp_Type != 'Physician') )
)
and
(
( (select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date= '#VARIABLES.date#') < e.SaturdayMaxVisit )
OR (SaturdayMaxVisit is null)
OR (SaturdayMaxVisit='0')
)
order by PreferenceCount desc,Emp_Last asc
select count(*) as Count from #Request.prefix_db_agency#.pSchedules
where
str_to_date('#STime#','%H:%i') between str_to_date(StartTime,'%H:%i') and str_to_date(EnDTime,'%H:%i') AND
str_to_date('#ETime#','%H:%i') between str_to_date(StartTime,'%H:%i') and str_to_date(EnDTime,'%H:%i') AND
Emp_ID='#Session.EmployeeID#' AND
Visit_Date = '#VARIABLES.date#';
Closed Match
SELECT case when Pt_Longitude is not null then Pt_Longitude else 0 end as LATITUDE,case when Pt_Longitude is not null then Pt_Longitude else 0 end as LONGITUDE,(SELECT DAYOFWEEK('#date1#')) as DAYOFDATE FROM #Request.prefix_db_agency#.pPatients WHERE PATIENT_ID='#Session.Patient.PatientIDValue#'
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID='#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i')) limit 1 ) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
( (Loc_ID ='#Session.AgencyID#')
and
((
SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and Emp_ID=e.Emp_ID
)
>0)
and (Status = '0')
and (Emp_Type<>'Physician'))
and
((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date= '#VARIABLES.date#')>e.SundayMaxVisit )
and ((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date= '#VARIABLES.date#')<=e.SundayMaxVisit+2 )
order by PreferenceCount desc,Emp_Last asc
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID= '#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))limit 1 ) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
(
(Loc_ID='#Session.AgencyID#')
and
((
SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and Emp_ID=e.Emp_ID
)
>0)
and (Status = '0')
and (Emp_Type<>'Physician')
)
and
((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#')>e.MondayMaxVisit )
and ((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#')<= e.MondayMaxVisit+2 )
order by PreferenceCount desc,Emp_Last asc
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID= '#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))limit 1 ) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
(
(Loc_id='#Session.AgencyID#')
and
(
(
SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and Emp_ID=e.Emp_ID
)
>0)
and (Status = '0')
and (Emp_Type<>'Physician')
)
and
((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date= '#VARIABLES.date#')>e.TuesdayMaxVisit )
and ((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#')<=e.TuesdayMaxVisit+2)
order by PreferenceCount desc,Emp_Last asc
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID= '#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount, ( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i')) limit 1 ) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
(
(Loc_ID='#Session.AgencyID#')
and
(
(
SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and Emp_ID=e.Emp_ID
)
>0)
and (Status = 'Active')
and (Emp_Type<>'Physician'))
and
((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date= '#VARIABLES.date#')>e.WednesdayMaxVisit )
and ((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#')<=e.WednesdayMaxVisit+2)
order by PreferenceCount desc,Emp_Last asc
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID= '#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))limit 1 ) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
(
(Loc_Id='#Session.AgencyID#')
and
(
(
SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and Emp_ID=e.Emp_ID
)
>0)
and (Status = '0')
and (Emp_Type<>'Physician') )
and
((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#')>e.ThursdayMaxVisit )
and ((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#')<=e.ThursdayMaxVisit+2)
order by PreferenceCount desc,Emp_Last asc
select Distinct Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID= '#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))limit 1 ) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.pEmployee e
where
(
(Loc_ID='#Session.AgencyID#')
and
((
SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and Emp_ID=e.Emp_ID
)
>0)
and (Status = '0')
and (Emp_Type<>'Physician')
)
and
((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date= '#VARIABLES.date#')>e.FridayMaxVisit)
and ((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#')<=e.FridayMaxVisit+2)
order by PreferenceCount desc,Emp_Last asc
select Emp_ID, concat(Emp_First,' ',Emp_Last) as Emp_Last,
(select count(*) from #Request.prefix_db_agency#.preferedpatient where Patient_ID= '#Session.Patient.PatientIDValue#' and EmployeeID=Emp_ID) as PreferenceCount,
( SELECT EmployeeWorkschedule_ID FROM #Request.prefix_db_agency#.Employee_Workschedule WHERE ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and (str_to_date('#STime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))
and (str_to_date('#ETime#','%H:%i') between str_to_date(ScheduleStart,'%H:%i') and str_to_date(ScheduleEnd,'%H:%i'))limit 1 ) as EmployeeWorkschedule_ID
from #Request.prefix_db_lookup#.Employee e
where
(
(Loc_Id='#Session.AgencyID#')
and
(
(
SELECT count(1) FROM #Request.prefix_db_agency#.Employee_Workschedule
WHERE
ScheduleType='available'
and ScheduleDate='#VARIABLES.date#'
and Emp_ID=e.Emp_ID
)
>0)
and (Status = '0')
and (Emp_Type<>'Physician')
)
and
((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#')>e.SaturdayMaxVisit)
and ((select count(*) from #Request.prefix_db_agency#.pSchedules WHERE Emp_ID=e.Emp_ID AND Visit_Date = '#VARIABLES.date#')<= e.SaturdayMaxVisit+2)
order by PreferenceCount desc,Emp_Last asc
Previous
#Pages#
#Pages#
Next
select count(*) as count from #Request.prefix_db_agency#.pAuths where Auth_ID = (select Auth_ID from #Request.prefix_db_agency#.pAuths where Patient_ID ='#GetPatient.Patient_Id#' and Rev_ID='#revenuelist.Payer_ID#' AND Status = '0'
order by Auth_ID desc limit 1) ;
select * FROM
#Request.prefix_db_agency#.pAuths a, #Request.prefix_db_lookup#.pRevenue_Code r
where a.Rev_ID='#Revcodeid#'
and a.Rev_ID = r.Rev_CodeID
and a.Patient_ID ='#GetPatient.Patient_Id#'
-- and a.PtPayer_ID='#revenuelist.Payer_ID#'
AND a.status = 0
Select the dates to schedule visits, by checking them on the calendar below.
select Auth_ID,Date_Start AS StartDate,Date_End AS EndDate from #Request.prefix_db_agency#.pAuths where Rev_ID='#Revcodeid#'
and Patient_ID ='#GetPatient.Patient_Id#' and PtPayer_ID='#revenuelist.Payer_ID#' AND
Status = 0 order by Auth_ID desc limit 1