Need to return next appt with date, time, appt type, provider/resource, and location of appt with address in CPS. I don't have access to a CPS DB so this is challenging and I can't test so need assistance from someone with CPS knowledge/access. I've cobbled together parts of previous posts for CPS appts and have this working for appts with providers but can't get the correct results for appts with a RESOURCE.
This part works and gets all of the details if scheduled with provider:
....
local i = getRowCount("_MELCurPatientAppt")
while i > 0 do
i = i-1
local a = getRow("_MELCurPatientAppt",i,"AppointmentsId","ApptStart","ApptTypeId","FacilityId","DoctorID","ResourceId","Status","Canceled")
if a[7] <> "Scheduled" then continue else "" endif
if val(b[1]) > ._todaysdate then date=b[1] else continue endif
if a[2] <> "" then b=getfield(a[2]," ","") time = b[2] + " "+b[3] else "" endif
if (find("_MELApptType","Name","ApptTypeID",a[3]) <> "") then
a[3] = find("_MELApptType","Name","ApptTypeID",a[3])
endif
if (find("_MELLocation","ListName","DoctorFacilityID",a[4]) <> "") then
loc_name = find("_MELLocation","ListName","DoctorFacilityID",a[4])
loc_address1=find("AllLocation","Address1","FacilityId",a[4])
loc_address2=find("AllLocation","Address2","FacilityId",a[4])
loc_city=find("AllLocation", "City","FacilityId",a[4])
loc_state=find("AllLocation","State","FacilityId",a[4])
loc_details=loc_name + " "+loc_address1 + " "+loc_address2+ " " + loc_city + ", " + loc_state
endif
...but must not be guessing correct object for resource - the following does not work:
if find("_MELLocation","ListName","DoctorFacilityID",a[6]) <> "" then
res_name = find("_MELLocation","ListName","DoctorFacilityID",a[6])
res_address1=find("AllLocation","Address1","FacilityId",a[6])
res_address2=find("AllLocation","Address2","FacilityId",a[6])
res_city=find("AllLocation", "City","FacilityId",a[6])
res_state=find("AllLocation","State","FacilityId",a[6])
res_details=res_name + " "+res_address1 + " "+res_address2+ " " + res_city + ", " + res_state
endif
Any help appreciated.
Regards,
Paul