2 Replies Latest reply on Oct 30, 2015 7:17 AM by tays01s

    Export records


      I have an export script below. Parts that work include:

      1. Patient files exported to the correct folder (not tested on Windows yet) and with the correct filename.

      2. Custom dialogue indicates successful export.


      Parts I'd like advice:

      3. The script exports 3 out of 4 available files. It doesn't only export those records where Patient::Export_record=1.

      4. Each exported file contains all the Patient:: fields of all 3 records regardless of the filename given. What I want is the record of only the named patient but I want it to include ALL the related records associated with that Patient record, for examples, all the related records shown in the portals of that record in the 'Patient_L' layout.


      Go to Layout [ “Patient_L” (Patient) ]

      If [ not IsEmpty(Patient::Export_record=1) ]

      Go to Record/Request/Page [ First ]

      [ $Device = 1 ]

      Set Variable [ $Filepath; Value:Get ( DesktopPath )&"FC_export files/"& Patient::Lastname& "_" & Patient::Firstname& "_" & Substitute (Patient::BirthDate ; "/" ; "_" ) & ".fmp12" ]

      Else If [ $Device = 2 ]

      Set Variable [ $Filepath; Value:"Get ( DesktopPath )&\"FC_export files\"&Patient::Last_Firstname&\".fmp12\"" ]

      End If

      Export Records [ File Name: “$Filepath” ] [ No dialog ]

      Go to Record/Request/Page [ Next; Exit after last ]

      End Loop
      Show Custom Dialog
      [ Title: "Export successful"; Message: "Find records on: Desktop > FC export_files"; Default Button: OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]

      Show Custom Dialog
      [ Title: "No records for export"; Message: "[X] checkbox those records you wish to export."; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]

      End If

        • 1. Re: Export records

          If [ not IsEmpty(Patient::Export_record=1) ]  makes me think too much, why not

          IF [ Patient::Export_record ]  ??

          and in any case, the if should be inside the loop, not outside...

          • 2. Re: Export records

            I used the 'not IsEmpty' to lead to a dialogue telling the user to 'X checkbox' some records, ie. select some for export.

            I put the 'if' outside the loop so that if there are no records for export, the script would hop straight to the above-mentioned dialogue.