Good Morning
I have been struggling with this and I am hoping for some CHUG knowledge. This is what I have in a letter to a patient regarding their upcoming appointment:
You are currently scheduled for a new patient appointment on {IF APPT_NEXT()="" THEN "NO APPOINTMENT SCHEDULED" ELSE global apptinfo = getfield (APPT_NEXT(),",","")
apptinfo[1] + " at " + apptinfo[2] + " at our " + apptinfo[4] + " location" ENDIF} with {PATIENT.PCP}. To date we have not received your prior medical records and have not been able to reach you by phone at {PATIENT.ALTPHONE} in regards to this request.
and this is what it produces:
You are currently scheduled for a new patient appointment on 11/09/2014 at 9:00 AM at our AMA American Medical Associates location with Winston MD, Harry. To date we have not received your prior medical records and have not been able to reach you by phone at (603) XXX-XXXX in regards to this request.
I am struggling with 2 things. The first is the appt info, I am trying to make it the next appointment at a specific Location of Care, and it just pulls the next appt regardless of LOC. The second is the way the Providers name is populated, I would like it to say Harry Winston MD.
Any insight would be greatly appreciated.
Laurie
For the pcp I would do something like
{fn PCPName(name){
if name == "" then return "" endif
if match(name,",")>0 then
local temp = getfield(name,",","")
return temp[2] + " " + temp1
else return name endif
}}{PCPName(PATIENT.PCP)}
For the appointment issue Im not sure that there is a built in function that will get you this reliably, I picked up a custom appointment function from this site somewhere and molded it to fit our needs, that route will probably be your best bet.
gibsonmi said:
For the pcp I would do something like
{fn PCPName(name){
if name == "" then return "" endif
if match(name,",")>0 then
local temp = getfield(name,",","")
return temp[2] + " " + temp1
else return name endif
}}{PCPName(PATIENT.PCP)}
For the appointment issue Im not sure that there is a built in function that will get you this reliably, I picked up a custom appointment function from this site somewhere and molded it to fit our needs, that route will probably be your best bet.
Thank you! The PCP worked great. I do have a function that we wrote for the next 3 appointments to populate the banner, but it doesn't give me the option of choosing the one that matches the place of service. Thanks again for your help.
Laurie
My function has this line
find("_MELLocation","ListName","DoctorFacilityID",a[4])
where a[4] is a reference to the field "FacilityId" in the "_MELCurPatientAppt" object that has already been returned.
That pulls in location of care, and then you could require a first match to return the right appointment, if you get stuck just post your code
Thanks Michael
I'll give it a try.
Laurie
Well it took some trial and error but we got it to work:
You are currently scheduled for a new patient appointment {! fn APPT_NEXT_PCP(PCP){
local retVal = ""
local i = getRowCount("_MELCurPatientAppt")
local t1Hour
local t1Minute
local t1AMPM
local t2Hour
local t2Minute
local t2AMPM
local currentTime
local apptDateTime
local temp
local PCPName
while i > 0 do
i = i-1
local a = getRow("_MELCurPatientAppt",i,"AppointmentsId","ApptStart","ApptTypeId","FacilityId","DoctorID","ResourceId","Status","Canceled","ApptKind")
if (a[8] <> "" or a[9] <> 1) then
continue
endif
/* Doctor lookup in _DoctorFacilityForPatAppt data object */
if (find("_DoctorFacilityForPatAppt","ListName","DoctorFacilityID",a[5]) <> "") then
a[5] = find("_DoctorFacilityForPatAppt","ListName","DoctorFacilityID",a[5])
endif
/* Make sure the appt is with the PCP */
if a[5] <> PCP then
continue
endif
/* Build PCP name */
if match(a[5],",")>0 then
temp = getfield(a[5],",","")
PCPName = temp[2] + " " + temp[1]
else
PCPName = a[5]
endif
/* Facility lookup in _MELLocation data object */
if (find("_MELLocation","ListName","DoctorFacilityID",a[4]) <> "") then
a[4] = find("_MELLocation","ListName","DoctorFacilityID",a[4])
endif
//Set up the time values for comparison
if size(TIMESTAMP()) == 7 then
currentTime = "0" + TIMESTAMP()
else
currentTime = TIMESTAMP()
endif
if sub(str(a[2]),13,1) == ":" then
apptDateTime = "0" + sub(str(a[2]),12,7)
else
apptDateTime = sub(str(a[2]),12,8)
endif
t1Hour = sub(currentTime, 1, 2)
t1Minute = sub(currentTime, 4, 2)
t1AMPM = sub(currentTime, 7, 2)
t2Hour = sub(apptDateTime, 1, 2)
t2Minute = sub(apptDateTime, 4, 2)
t2AMPM = sub(apptDateTime, 7, 2)
// Build the result if date is in the future
if
(
DURATIONDAYS(sub(str(a[2]),1,10),str(._TODAYSDATE)) > 0
or
(
DURATIONDAYS(sub(str(a[2]),1,10),str(._TODAYSDATE)) == 0
and
timeCompare(t1Hour,t1Minute,t1AMPM,t2Hour,t2Minute,t2AMPM) == 1
)
) then
break
else
retVal = str("on ",sub(str(a[2]),1,10)," at ",t2Hour,":",t2Minute," ",t2AMPM," with",PCPName," at our ",a[4]," location.")
endif
endwhile
if retVal == "" then
retVal = "NO APPOINTMENT SCHEDULED."
endif
return retVal
}}{APPT_NEXT_PCP(PATIENT.PCP)}
Produces this:
You are currently scheduled for a new patient appointment on 05/14/2014 at 08:40 AM with Harry Winston MD at our AMA American Medicine Association location.
It looks at the PCP and pulls the next appointment associated with the PCP. Just thought I would share.
Laurie