This example script can be used on the frmEditorPatient – OnAfterLoadScreen event to display some information in a MessageBox when a patient record is loaded.
using System.Collections.Generic;
using System.Data;
frmEditorBaseRec Editor = (Params[0] as frmEditorBaseRec);
cPer per = (Editor.Record as cPer);
cDBBaseRec custom = (Editor.Records[1]);
DataTable tbl = cGlobals.DB.GetCannedTable("select count(*) from app where per_id=" + per.id);
if (tbl.Rows.Count > 0)
{
int num_appts = Convert.ToInt32(tbl.Rows[0][0]);
PSDevEx.cMessages.InformationBox("This patient has " + num_appts + " appointment(s)");
}