Viewing 1 post (of 1 total)
  • Author
    Posts
  • #31135
    Support
    Keymaster

    [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 :-

    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.

    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 :-

    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!

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.