Does anyone have code they can share for next appt? The data symbol {APPT_NEXT()} doesn't work for us because it lists the person who booked the appt, not the book name. I just discovered that the code I was using below in usrlib.txt lists am instead of pm between noon and 12:59 p.m. and users are complaining.
//APPT (ALL FUTURE) FUNCTION
fn SMRMC_APPT_ALL_FUTURE() {
//lists all future appts with a comma between fields a hret between records
//use nested getfields to turn in to a 2D array if you want to pick elements
//DN–3-31-04 modified from mellib stock function
local a, b,c, loc, atype, book, i = 0
local result=''
local j = getRowCount('_MELCurPatientAppt')
// Loop thru patients appointments
if j == 1 then a = getRow('_MELCurPatientAppt',0, 'ApptDate',
'ApptTime','Appttype','Booklist','ApptStatus')
// Find the next appointmnet
if val(a[1]) >= ._TODAYSDATE and val(a[5]) = 0 then
// Get the type of appointment
atype = find('_MELApptDef', 'ApptType', 'ID', a[3])
// Get the location of care from the first book
b = getfield(a[4],',',' :')
loc = find('_MELBook', 'LocationAbbrevName', 'ID',b[1])
//Get the Book Name
c = getfield(a[4],',',' :')
book = find('_MELBook', 'Name', 'ID',c[1])
// Build the result
result = a[1] + ',' + appttime(a[2]) + ',' + atype + ',' + book
//edit previous line if you want to return only part or use different
delimiters etc
//note this first part is if theres only 1 appointment
endif
else if j > 1 then
while i < j do
i = i+1
a = getRow('_MELCurPatientAppt',i,
'ApptDate','ApptTime','Appttype','Booklist','ApptStatus')
// Find the next appointmnet
if val(a[1]) >= ._TODAYSDATE and val(a[5]) = 0 then
// Get the type of appointment
atype = find('_MELApptDef', 'ApptType', 'ID', a[3])
// Get the location of care from the first book
b = getfield(a[4],',',' :')
loc = find('_MELBook', 'LocationAbbrevName', 'ID',b[1])
//Get the Book Name
c = getfield(a[4],',',' :')
book = find('_MELBook', 'Name', 'ID',c[1])
// Build the result
if result=="" then
result = result + a[1] + ',' + appttime(a[2]) + ',' +
atype + ',' + book else result = result + hret + a[1] + ',' + appttime(a[2])
+ ',' + atype + ',' + book endif
//edit previous line if you want to return only part or use different
delimiters etc
//this part there are 2 or more appointments or rows
endif
endwhile
endif
endif
result
}
Stacey LaGrange
Software Developer/Analyst
St. Mary's Health System
[email protected]
(207) 777-8410
APPT_NEXT() showing who made the appointment is a bug and was reported on CISDB00047210 per the GE tech I communicated with. You could call and reference that number and get on the SPR to get notified
David
Thank you, I will do this.
Not sure if you're still interested, but I'll include the code I use to pull in the patient's future appointments. I originally found this code in another form, then probably tweaked it some to display the way I want -- sorry I can't credit the original author!
/*
Function to display details of future appointments.
*/
!fn APPT_DISPLAY() {
local a, b, c, d, loc, atype, book, stat
local i = 0
local result=''
local j = getRowCount('_MELCurPatientAppt')
// Loop thru patients appointments
while i < j do
i = i+1
a = getRow('_MELCurPatientAppt',i,'ApptDate', 'ApptTime',
'Appttype', 'Booklist', 'ApptStatus')
// Find the next scheduled appointment
If val(a[1]) >= ._TODAYSDATE Then
// Get the type of appointment
atype = find('_MELApptDef', 'ApptType', 'ID', a[3])
if atype == "" then
atype = "UNKNOWN"
endif
// Get the location of care from the first book
if a[4] == "" then
loc = "UNKNOWN"
else
b = getfield(a[4],',',' :')
loc = find('_MELBook', 'LocationAbbrevName', 'ID', b[1])
endif
//Get the Book Name
if a[4] == "" then
book = "UNKNOWN"
else
c = getfield(a[4],',',' :')
book = find('_MELBook', 'Name', 'ID', c[1])
endif
//Get the Status 0 Scheduled, 1 No Show, 2 Cancelled, 3 Arrived
d = a[5]
cond
case d == 0 stat = "Scheduled"
case d == 1 stat = "No Show"
case d == 2 stat = "Cancelled"
case d == 3 stat = "Arrived"
endcond
// Build the result if status is 0 Scheduled or 3 Arrived
if stat == "Scheduled" OR stat == "Arrived" then
result = result + a[1] + " at " + appttime(a[2]) + " " + atype + " with " + book + HRET
endif
endif
endwhile
return result
}
This code will list the next, or all, future appts for the current user, or all users:
{ListFutureAppointments("list", "mine", "next")}
{ListFutureAppointments("list", "mine", "all")}
{ListFutureAppointments("list", "all", "next")}
{ListFutureAppointments("list", "all", "all")}
{fn ListFutureAppointments(arg, mine, next)
{
local rec_delim = ""
local field_delim = ""
local count
local appt = array()
local atype
local book = array()
local bookcount
local loc
local username
local i = 0
local j
local status
local result = ""
if arg=="delim" then
rec_delim = "|"
field_delim = "^"
else
rec_delim = hret
field_delim = ", "
endif
count = GETROWCOUNT("_MELCurPatientAppt") // _MEL???? are global variables from mellib.txt
// Loop thru patients appointments and stop after first for current user
while i<count
and (next<>"next"
or (result==""
and next=="next")) do
appt = GETROW("_MELCurPatientAppt", i, "ApptDate", "ApptTime", "Appttype", "Booklist", "ApptStatus")
// Check for future appointment
if VAL(appt[1])>=._TODAYSDATE then
// Is appointment still scheduled
if VAL(appt[5])==0 then
// Get the type of appointment ... ApptType from _MELApptDef where ID = appt[3]
atype = FIND("_MELApptDef", "ApptType", "ID", appt[3])
// Get the books associated with appointment
book = GETFIELD(appt[4], ":", "")
bookcount = SIZE(book)
// Loop thru books
j = 2
while j<bookcount do
// Get the location of care from the each book
loc = FIND("_MELBook", "LOCID", "ID", book[j])
loc = FIND("_MELLoc", "Name", "LOCID", loc)
// Get the user name from the each book
username = FIND("_MELBook", "UserName", "ID", book[j])
// Build the result if book matches current user
if mine=="all"
or (mine=="mine"
and MATCH(username, 1, user.firstname)>0
and MATCH(username, 1, user.lastname)>0) then
if result<>"" then
result = result + rec_delim
endif
result = result + appt[1] + field_delim + appttime(appt[2]) + field_delim + loc + field_delim + username
endif
j = j + 1
endwhile
endif
endif
i = i + 1
endwhile
return result
}
}
Thanks I just tried and it worked great except that appts between noon and 12:59 pm were blank. I am not having very much luck with this I guess.
I got this code from someone else and nobody has complained of it not working, but the following line doesn't look correct:
if VAL(appt[1])>=._TODAYSDATE then
Should probably be:
if DURATIONDAYS(appt[1], str(._TODAYSDATE))>0 then
Actually my last reply was for Jennifer's code so I tried yours but I had the same problem with am pm between noon and 12:59 being incorrect. I tried the change you suggested but it didn't work at all after that. Maybe I have issues with our mldefs3.txt file? We have been live since 1998 so maybe mine were never updated properly.
Check your mellib.txt file for appttime function. Ours shows:
fn appttime(time) {
local ampm = 'am'
local dhours = time/3600
local hours = truncate(dhours)
local dmin = (dhours - hours)*60
local min = round(dmin)
local smin = str(min)
if (hours > 12) then
hours = hours - 12
ampm = 'pm'
endif
if size(smin) <= 1 then smin = '0'+smin endif
hours + ':' + smin + ' ' + ampm
}
Good idea! Mine looks just like yours though. Have you tried booking an appt, maybe sometime right after noon, like 12:15 to see if yours says am or pm. I am just wondering if yours works correctly. It tooks years before anyone noticed our issue.
looked at appttime...not correct...should set to pm if hours > 11:
fn appttime(time) {
local ampm = 'am'
local dhours = time/3600
local hours = truncate(dhours)
local dmin = (dhours - hours)*60
local min = round(dmin)
local smin = str(min)
if (hours > 12) then
hours = hours - 12
endif
if (hours > 11) then
ampm = 'pm'
endif
if size(smin) <= 1 then smin = '0'+smin endif
hours + ':' + smin + ' ' + ampm
}
You were right that worked, thanks so much!
where is the mellib.txt file located?
Thanks!
C:\Program Files\Centricity EMR 9.5
slagrang said:
Thanks I just tried and it worked great except that appts between noon and 12:59 pm were blank. I am not having very much luck with this I guess.jjordet said:
This code will list the next, or all, future appts for the current user, or all users:
{ListFutureAppointments("list", "mine", "next")}
{ListFutureAppointments("list", "mine", "all")}
{ListFutureAppointments("list", "all", "next")}
{ListFutureAppointments("list", "all", "all")}
{fn ListFutureAppointments(arg, mine, next)
{
local rec_delim = ""
local field_delim = ""
local count
local appt = array()
local atype
local book = array()
local bookcount
local loc
local username
local i = 0
local j
local status
local result = ""
if arg=="delim" then
rec_delim = "|"
field_delim = "^"
else
rec_delim = hret
field_delim = ", "
endif
count = GETROWCOUNT("_MELCurPatientAppt") // _MEL???? are global variables from mellib.txt
// Loop thru patients appointments and stop after first for current user
while i<count
and (next<>"next"
or (result==""
and next=="next")) do
appt = GETROW("_MELCurPatientAppt", i, "ApptDate", "ApptTime", "Appttype", "Booklist", "ApptStatus")
// Check for future appointment
if VAL(appt[1])>=._TODAYSDATE then
// Is appointment still scheduled
if VAL(appt[5])==0 then
// Get the type of appointment ... ApptType from _MELApptDef where ID = appt[3]
atype = FIND("_MELApptDef", "ApptType", "ID", appt[3])
// Get the books associated with appointment
book = GETFIELD(appt[4], ":", "")
bookcount = SIZE(book)
// Loop thru books
j = 2
while j<bookcount do
// Get the location of care from the each book
loc = FIND("_MELBook", "LOCID", "ID", book[j])
loc = FIND("_MELLoc", "Name", "LOCID", loc)
// Get the user name from the each book
username = FIND("_MELBook", "UserName", "ID", book[j])
// Build the result if book matches current user
if mine=="all"
or (mine=="mine"
and MATCH(username, 1, user.firstname)>0
and MATCH(username, 1, user.lastname)>0) then
if result<>"" then
result = result + rec_delim
endif
result = result + appt[1] + field_delim + appttime(appt[2]) + field_delim + loc + field_delim + username
endif
j = j + 1
endwhile
endif
endif
i = i + 1
endwhile
return result
}
}