7 Replies Latest reply on Apr 5, 2011 10:11 AM by rmen

    Script help

    rmen

      Title

      Script help

      Post

      I would like to make a new record for a patient.  I would also like the new record to automatically enter the patient's serial auto-enter ID number in the PatientNumber field (this is one number for all records fot that patient).  I write a script

      New Record Request

      Got Field [Assessments::PatientNumber]

      Insert From Last Visited [Select; Assessments::PatientNumber]

      What I hope will happen is that a new record is open, and that patient's serial ID number is entered for me, rather than have to select the number from the drop down list with all patient number.  What does happen is that the new record is opened and there's a blinking cursor within the PatientNumber field.

      Ram

        • 1. Re: Script help
          RickWhitelaw

          If you're saying the Patient Number is identical to the auto-entered serial number, I don't see any advantage to having the same data in two different fields of the same table. Simply use the auto-entered serial ID for whatever purpose you need. Make sure it cannot be modified by the user (even you) however because this would break any relationships depending on this field.

             Each patient would, I'm assuming, have only one record, with records in child tables for anything else (appointment history, current meds etc.).

          • 2. Re: Script help
            rmen

            THanks

            The PatientNumber field on the Assesment Layout, when selected enters a lot of identifying data for that patient, which otherwise would need to be entered individually.   Having the Patient Number field on this layout is one way of identifying the record.  But what is wrong with the script that the value from the last record isn't entered for me? (The script is not paused)

            • 3. Re: Script help
              rmen

              Sorry, each patient has multiple 'child' records based on one parent record.

              • 4. Re: Script help
                philmodjunk

                If your child records are displayed in a portal on the patient record and "allow creation of records via this relationship" is enabled. This will happen automatically.

                If you do not use the portal, you have to set this up yourself as FileMaker has no way to "know" which parent record should be linked to the new child record. How you set this up depends on your layout design. If you start with the patient layout, you can write a script that captures the PatientID in a variable, goes to the child layout, creates a new record and enters the PatientID for you. This script can also put this number in either a global field or a global variable and then an auto-enter calculation defined for the child record's PatientID field can copy the value from this global field or variable into the new record's PatientID field.

                • 5. Re: Script help
                  rmen

                  This is about trying to make a new child record from an existing one via a button.  While on the assessment layout in browse mode, I'm clicking on a button called 'New" which should bring up a new assessment record with the patient number already entered.  The Patient Number, is a serial number on the Patient layout. in the related layouts, it's a Number chosen from the Field- Patient::PatientNumber so that the child record in Assessment (And Discharge) show the same number as the Patient (parent) record.

                  • 6. Re: Script help
                    philmodjunk

                    Before you can do this, you have to select a patient record at least once. How will you do that? If you find the patient record on the Patient layout and click a button to switch to this layout, the script can capture the PatientID number and put it in a global variable:

                    set variable [ $$PatientID ; value: Patients::PatientID ]
                    Go to layout [assessment]

                    In the assessment table, define this auto-enter calculation on its patient ID field:

                    $$PatientID

                    Every new record in this table will then automatically get the value stored in the global variable.

                    • 7. Re: Script help
                      rmen

                      Neat!

                      That has fixed that.  And I was able to use the variable in other scripts while opening other layouts!

                      Thanks PhilModJunk.  Invaluable support.