3 Replies Latest reply on May 31, 2012 9:39 AM by philmodjunk

    Detect duplicate record

    RedzwanLatif

      Title

      Detect duplicate record

      Post

      Show Custom Dialog ["Patient Check-In"; "Please enter patient's Ic number"; Patient::gCheckInIC]
      If [Get (LastMessageChoice) = 1
         Freeze Window
         Go to Record/Request/Page [First]
         If [Patient::IC = Patient::gCheckInIC]
             Go to Related Record [From table: "Patient"; Using layout; "Patient Page" (Patient)]
         Else
             Loop
               Go to Record/Request/Page [Next; Exit after last]
               If [Patient::IC = Patient::gCheckInIC]
                   Go to Related Record [From table: "Patient"; Using layout; "Patient Page" (Patient)]
               End if
             End Loop
          End If
      Else
          Go to layout [Main Menu]
      End If
      Set Field [Patient::gCheckInIC; ""]

      Hi. I've done a script to detect duplicate records. But, I need the script to go to the other layout if there is no duplicate record detected. I tried to put "Else" but it didn't work. Can you help me with this script?

      Thanks in advance :)

        • 1. Re: Detect duplicate record
          philmodjunk

          Show Custom Dialog ["Patient Check-In"; "Please enter patient's Ic number"; Patient::gCheckInIC]
          If [Get (LastMessageChoice) = 1
             Freeze Window
             Go to Record/Request/Page [First]
             If [Patient::IC = Patient::gCheckInIC]
                 Go to Related Record [From table: "Patient"; Using layout; "Patient Page" (Patient)]
                
          exit Script []
             Else
                 Loop
                   Go to Record/Request/Page [Next; Exit after last]
                   If [Patient::IC = Patient::gCheckInIC]
                       Go to Related Record [From table: "Patient"; Using layout; "Patient Page" (Patient)]
                       exit Script []
                   End if
                 End Loop
                 # you only get here if patient record was not found
                 Go To layout [Specify the layout you want here]
               End If
          Else
              Go to layout [Main Menu]
          End If
          Set Field [Patient::gCheckInIC; ""]

          But you can use a much simpler script for this:

          Show Custom Dialog ["Patient Check-In"; "Please enter patient's Ic number"; Patient::gCheckInIC]
          If [Get (LastMessageChoice) = 1
             
          Enter Find Mode [] //clear the pause check box
             Set Field [Patient::IC ; Patient::gCheckInIC]
             
          Set Error Capture [on] //This step keeps "no records found" dialog from interrupting the script
             Perform Find []
             If [Get ( FoundCount ) //a record was found]
                Go to Related Record [From table: "Patient"; Using layout; "Patient Page" (Patient)]
             Else
                Go To Layout [Specify the layout you want when patient record is not found here]
             End If
          End IF

          Note: I am assuming that Patient::gCheckInIC is a field with global storage specified.

          • 2. Re: Detect duplicate record
            RedzwanLatif


               If [Get ( FoundCount ) //a record was found]
                  Go to Related Record [From table: "Patient"; Using layout; "Patient Page" (Patient)]
               Else
                  Go To Layout [Specify the layout you want when patient record is not found here]
               End If

            Is it for finding duplicate records?

            • 3. Re: Detect duplicate record
              philmodjunk

              It does exactly what your script is set up to do.

              If finds any existing records that match to the value entered in the global field. Your script does the same.

              (Your script does not find duplicate records either.)