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.
Posted : March 25, 2014 11:18 pm