Page 1 of 1

find appointments assigned to a operatory

Posted: Tue Jan 17, 2017 7:11 am
by babysilvertooth
Tryign to hid an unused operatroy, but OD tells me there are appointments in the future tied to that op. HOw do I find out where they are?

Thanks

Re: find appointments assigned to a operatory

Posted: Tue Jan 17, 2017 8:04 am
by cmcgehee
Query 848 will work for that. Just set the operatory name and VISIBLE up top.

Code: Select all

/*848 Scheduled appointments in specific operatory.*/
/*Query code written/modified:  01/17/2017*/
SET @OperatoryName='%%';/*To search for all Operatories, set OperatoryName='%%'*/
SET @OperatoryVisibility='HIDDEN';/*Accepted inputs are 'VISIBLE' or 'HIDDEN'.  All other inputs will default to 'HIDDEN'.*/
SELECT p.PatNum AS 'Pat#',p.LName, p.FName, DATE_FORMAT(ap.AptDateTime,'%m/%d/%Y - %h:%i %p') AS 'Appt Date/Time', op.OpName AS 'Operatory'
FROM appointment ap
INNER JOIN operatory op ON op.OperatoryNum=ap.Op
	AND (CASE WHEN @OperatoryVisibility LIKE '%HIDDEN%' THEN op.IsHidden=1 
		ELSE op.IsHidden=0 END)
	AND op.OpName LIKE @OperatoryName
INNER JOIN patient p ON p.PatNum=ap.PatNum
WHERE ap.AptStatus IN (1,4)
ORDER BY op.OpName, ap.AptDateTime;

Re: find appointments assigned to a operatory

Posted: Tue Jan 17, 2017 8:26 am
by babysilvertooth
Thanks!

Re: find appointments assigned to a operatory

Posted: Tue Jan 17, 2017 9:42 am
by cmcgehee
Glad to be of help!