AnsweredAssumed Answered

Need help with a find script

Question asked by WendellNeeley on Feb 13, 2013
Latest reply on Feb 13, 2013 by philmodjunk

Title

Need help with a find script

Post

     Hi all,

     I need some help with a script that I have put together for my database.  I have a table that is for patients and I want to have a "check" step when adding in new patients to try and prevent double entries (the script is attached to a button).  In doing so, I have chosen to utilize three global fields for the first name, last name and birthdate.  I use these values to input, via a script, into search fields within the table to see if any records exist with those names and birthdate.

     The script is acting in a very unpredictable fashion for me.  Sometimes it will work exactly as intended, and then at other times it will reject a name/birthdate combo that I know is not in the database as already present.  

     Here is the script that I have right now:

     Set Variable [$COUNT; Value:Get (FoundCount)

     Set Error Capture [On]

     Go to Layout ["New Patient Master Layout" (Patient Demographic)]

     Show All Records

     Enter Find Mode []

     Set Field [Patient Demographic::Pt_FName; Patient Demographic::GlobalPatient_FName_search]

     Set Field [Patient Demographic::Pt_LName; Patient Demographic::GlobalPatient_LName_search]

     Set Field [Patient Demographic::Birthdate; Patient Demographic::GlobalPatient_BDay_search]

     Perform Find []

     If [$COUNT > 0]

     Go to Layout ["New Patient Master Layout" (Patient Demographic)]

     Enter Find Mode []

     Set Field [Patient Demographic::Pt_FName; Patient Demographic::GlobalPatient_FName_search]

     Set Field [Patient Demographic::Pt_LName; Patient Demographic::GlobalPatient_LName_search]

     Set Field [Patient Demographic::Birthdate; Patient Demographic::GlobalPatient_BDay_search]

     Perform Find []

     Show Custom Dialog ["There is already a patient with this name and birthdate in the database."]

     Else If [$COUNT = 0]

     Go to Layout ["New Patient Master Layout" (Patient Demographic)]

     New Record/Request

     Set Field [Patient Demographic::Pt_FName; Patient Demographic::GlobalPatient_FName_search]

     Set Field [Patient Demographic::Pt_LName; Patient Demographic::GlobalPatient_LName_search]

     Set Field [Patient Demographic::Birthdate; Patient Demographic::GlobalPatient_BDay_search]

     End If

     Set Field [Patient Demographic::GlobalPatient_BDay_search; ""]

     Set Field [Patient Demographic::GlobalPatient_FName_search; ""]

     Set Field [Patient Demographic::GlobalPatient_LName_search; ""]

     Exit Script

      

     So I don't know if this is even the best strategy for trying to limit double entries, but I have had it work before.  I don't know if I've missed something.

      

      

      

         

Outcomes