How to make a field mandatory in the Patient Editor?

Scripting help and sample scripts for use with the Scripting Module
Post a reply

How to make a field mandatory in the Patient Editor?

Postby Support » September 7th, 2010, 3:52 pm

[1] Click TOOLS | SCRIPT EDITOR to show the Script Editor screen

[2] Locate "frmEditorPatient" and the "OnBeforeSaveRecord" event

[3] Copy & Paste the following script into the Script Editor :-

Code: Select all
frmEditorBaseRec Editor = (Params[0] as frmEditorBaseRec);
cPer per = (Editor.Record as cPer);
if (per.dob == null)
{
  throw new PSExc.FriendlyException("Please enter the Patient's DOB", "D.O.B Required");
}

This example works on the "per.dob" field i.e. the patient's Date of Birth. Of course, you could edit this script to work on a different field.

Please click here to see a full list of the fields available on the PER object (PER = PERson).

Let's say that you wanted to make the telephone mandatory instead, you would simply need to check the field per.telephone instead of per.dob.

There would be a couple of other small changes too.
[1] Telephone is a TEXT field while date of birth is a DATE field so you in addition to checking for a NULL value (i.e. undefined), you would also want to check if someone has entered an empty string.
[2] You'd want to change the message to something more appropriate i.e. about the "Telephone Number" rather than the "Date of Birth"

Hence, the whole script would now be as follows :-

Code: Select all
frmEditorBaseRec Editor = (Params[0] as frmEditorBaseRec);
cPer per = (Editor.Record as cPer);
if (per.telephone == null || per.telephone == "")
{
  throw new PSExc.FriendlyException("Please enter a telephone number", "Tel Num Req'd");
}



Hope this is helpful! Please feel free to post a reply if you have any questions or need something to be clarified!
ClinicOffice Support Team
User avatar
Support
Site Admin
 
Posts: 875
Joined: August 25th, 2005, 6:37 pm
Top

Post a reply

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest

cron