I've been beating my head against this banner formula for days now, and I keep getting the same problem no matter what I do. The objective is to determine whether a patient is new or established based on whether they've been seen at one of our practices in the past three years.
{! fn NEW_OR_ESTABLISHED(){
local retVal = "New patient"
local apptCount = getRowCount("_MELPastPatientAppt")
local i = 0
local a
local loc = array(344,369,367,375,373,365,359,2015,2209,2430,5435)
while i < apptCount do
i = i + 1
a = getRow("_MELPastPatientAppt",i,"ApptKind","EmrApptStart","FacilityId")
/* Check for patient appointment */
if a[1] <> 1 then
continue
endif
/* Check for date range */
if DURATIONDAYS(sub(str(a[2]),1,10),str(._TODAYSDATE)) < 1095 then /*pass date check*/
if match(loc,a[3]) > 0 then /*pass date and PPA check*/
retVal = "Established patient"
break
else
continue
endif
else
break
endif
return retVal}}
{NEW_OR_ESTABLISHED()}
In the banner, the last two lines are:
return retVal} <- COMPILER ERROR NEARBY: [...]
{NEW_OR_ESTABLISHED()} <- FUNCTION DEFINITION NOT EXECUTABLE
I've been over this six ways to Sunday and I just don't see what I'm doing wrong. I even tried removing the last bracket, and it just prints out the text of the formula. Can anyone shed some light?
thanks,
ron
You are missing an ENDWHILE for your WHILE....
DavidShower said:
You are missing an ENDWHILE for your WHILE....
God I feel stupid. It still doesn't work, but at least now it doesn't blow up. Thank you David.
Should be easier to trace now and see what is really happening.
Once you get this working could you share, I would interested in what else could be done with the code.
adaniel said:
Once you get this working could you share, I would interested in what else could be done with the code.
Sure, glad to.
1. First I added this to mellib.txt:
global _MELPastPatientAppt = _PatientAppointmentsPast
2. Then I added this to mldefs3.txt. This is a modification of _PatientAppointments that looks at appointments in the past:
Object: _PatientAppointmentsPast Table: Appointments Refresh: RBook
Property: Snapshot
Property: Prepare
Field: AppointmentsId Type: ID Hidden Key
Field: FacilityId Type: Long
Field: ApptKind Type: Long
Field: OwnerId Type: Long
Field: EmrApptStart Type: DateTime
Field: ApptStart Type: DateTime
Field: ApptStop Type: DateTime
Field: Status Type: String Length: 50
Field: Canceled Type: Long
Field: PatientCheckIn Type: Long
Field: PriorAuthorizationNumber Type: String Length: 50
Field: WCCId Type: Long
Field: Notes Type: CLOB
Field: ApptStatusMId Type: Long
Field: DoctorId Type: Long
Field: ResourceId Type: Long
Field: Type Type: String Length: 50
Field: PatientVisitId Type: Long
Field: TicketNumber Type: String Length: 20
Field: HideNewVisit Type: Short
Field: ApptTypeId Type: Long
Field: ApptSetId Type: Long
Field: ApptChainId Type: Long
Field: RoomNo Type: String Length: 30
Field: CasesId Type: Long
Field: CompanyId Type: Long
Field: ExternalApptId Type: String Length: 75
Field: DocCreate Type: Short
Field: DocId Type: Double
Field: CreatedBy Type: String
Filter: filter1, OwnerId = Patient.PatientProfileId Hidden
Variable: dateVar Type: Date Hidden
Filter: dateFilter, EmrApptStart < dateVar Disable Hidden
Order: 'ApptStart DESC'
3. Finally, I added this to the banner to display whether the patient was new or established. If they've been seen in one of a list of practices in the past three years, they're established. Otherwise, they're new.
{! fn NEW_OR_ESTABLISHED(){
local retVal = "New patient"
local apptCount = getRowCount("_MELPastPatientAppt")
local i = 0
local a
local loc = array("344","369","367","375","373","365","359","2015","2209","2430","5435")
while i < apptCount do
i = i + 1
a = getRow("_MELPastPatientAppt",i,"ApptKind","EmrApptStart","FacilityId","Status")
/* Check for completed patient appointment */
if (a[1] <> 1 OR a[4] <> "Completed") then
continue
endif
/* Check for date range */
if DURATIONDAYS(sub(str(a[2]),1,10),str(._TODAYSDATE)) < 1095 then /*passes date check*/
/* Check for practice */
if match(loc,a[3]) > 0 then /*passes date and PPA check*/
retVal = "Established patient"
break
else
continue
endif
else
break
endif
endwhile
return retVal}}{NEW_OR_ESTABLISHED()}
I'm still fine-tuning it to account for the fact that a user might be entering a charge for an appointment that took place yesterday. The patient may have been new on Monday, but by the time they enter the charge on Tuesday, it's going to say they're established. I'm considering putting in a buffer but we haven't made any decisions yet.
Wow thanks definitely a little out of my realm in programming experience but I can learn from this, thank you.
So are you actually modifying the text file that the Patient banner uses? Or am I way off.