7 Replies Latest reply on Nov 13, 2014 3:47 PM by philmodjunk

    Perform Script with a calculated script name?

    SteveFransen_1

      Title

      Perform Script with a calculated script name?

      Post

      Using scripts, I need to get and set data from records in 22 tables whose fields contain data about different components of an eye exam. For example, the History table has one text field where the patient's history is entered. On the other hand, the VisualAcuity table has text fields for the right eye distance vision, left eye distance vision, right eye near vision, etc.

       

       

      I have Get scripts to get the field data, and Set scripts to set the field data for a record in each table. For example, the GetVisualAcuity and SetVisualAcuity scripts Get and Set the data from the fields in the VisualAcuity table. 

      I can set up a 22 branch If Else If conditional statement to call each Get or Set function but would rather have a single call to a calculated script name. I don't think I can do this with Perform Script. Is there a way to make this work?

      Thanks 

       

       

       

        • 1. Re: Perform Script with a calculated script name?
          philmodjunk

          You are correct in your conclusions. But I don't see why it is necessary to use 22 different scripts to move data from 22 different tables. A single script can do it all.

          And such a wholesale copying of data suggests a less than optimum design of your data model in the first place.

          • 2. Re: Perform Script with a calculated script name?
            SteveFransen_1

             

            But I don't see why it is necessary to use 22 different scripts to move data from 22 different tables. A single script can do it all.

            Yes, but from the code maintenance perspective it seems simpler to make separate Get and Set scripts that are called from a simpler parent script.

            And such a wholesale copying of data suggests a less than optimum design of your data model in the first place.

            I'm always interested in learning more about optimal data models. Each of these tables represents one element of the exam that can have very different fields. For example, the history table contains a single text field (and the associated housekeeping fields). On the other hand, the muscle balance table has 54 numeric fields to capture the data associated with a single measurement of eye alignment.

            I may have conveyed the wrong thing about copying. It's not happening for all 22 tables at the same time. When the user clicks on a portal in a popover, the fields from the row they clicked on need to be copied to another record. Rather than write a separate script to manage the copy for each table, I'm trying to write one reusable script that "knows" how to do the copy depending on which table it's managing.

            Thanks

            • 3. Re: Perform Script with a calculated script name?
              philmodjunk

              Yet your "simpler" seems much more complicatedwink Simple individual scripts, each that does both the "read" and the "write" with no single controlling script that takes a script parameter (or active field name) and decides what to do seems simpler overall.

              On the other hand, while the script name cannot be calculated, the reference to the field--both the field name and the table occurrence name that make up a typical TableOccurrenceName::FieldName reference CAN be calculated and used with GetField to "read" the data and with Set field by name to "write" the data, so maybe you just need to use one "write" script with one "read" script and calculate the table, field references...

              I may have conveyed the wrong thing

              But why do you need to copy this data at all?

              • 4. Re: Perform Script with a calculated script name?
                SteveFransen_1

                But why do you need to copy this data at all?

                When the user selects a row (in a portal on a popover), the data in the row they select needs to replace the data in the current record on the main layout.

                • 5. Re: Perform Script with a calculated script name?
                  philmodjunk

                  You have answered "what", but I asked "why". Why is it necessary to copy over the data? In many cases, there is an alternative that does not duplicate the same data in two different places. In other cases, that's not what you need.

                  • 6. Re: Perform Script with a calculated script name?
                    SteveFransen_1

                    Hi Phil,

                    The why is to save time by minimizing duplicate data entry.

                    Here's more of the what...

                    History and HistoryPopover are two occurrences of one table. HistoryPopover records are displayed as portal rows located on a popover.

                    Rather than duplicating data, I'm updating a History record with the data from a HistoryPopover record. It's all the same table.

                    A technician goes into a patient's room and enters the history they get from talking with the patient. That creates a History record. A few minutes later a medical student goes into the room and enters the history they get from talking with the patient. That creates a second History record. A few minutes later the physician reviews the History records created by the technician and medical student by looking at the HistoryPopover portal rows. Then the physician goes into the room and talks with the patient. At that point the physician can select a HistoryPopover portal row created by the technician or medical student. Clicking or tapping on that row creates a new (physician) History record containing the data from the technician's or medical student's history. Alternatively, the physician can create an entirely new blank History record of their own.

                    If the technician or medical student history is accurate, the physician saves time by simply choosing one of the technician or medical student portal rows rather than reentering that data manually. It's also a good starting point for the physician to edit if the technician or medical student history is fairly accurate but the physician wants to make some changes.

                    I'm always interested in suggestions about better designs and appreciate all the help you provide on this forum!

                     

                     

                    • 7. Re: Perform Script with a calculated script name?
                      philmodjunk

                      The why is to save time by minimizing duplicate data entry.

                      yet duplicating the data is exactly what your scripts do.

                      Instead of copying the data, you can simply change a value in one field to "mark" it as the official record for that visit to that patient. No copying of data needed at all.