2 Replies Latest reply on Sep 21, 2015 6:08 AM by tays01s

    Reset field and update evaluation2

    tays01s

      Followng: Reset field and update evaluation

      I'd got the script:

       

      Set Field [ Patient::IO_n; IO 2::__ID ]
      Set Variable [ $nutcalc_ioID; Value:Patient::IO_n ]

      Commit Records/Requests [ No dialog ]

      Go to Layout [ “Nut_calcs” (Nut_calcs) ]

      Go to Record/Request/Page [ First ]

      Loop

      Set Field [ Nut_calcs::_IDIO; $nutcalc_ioID ]

      Set Field [ Nut_calcs::Nut; Evaluate(Nut_eqs::Nut) ]

      + some other fields

      Go to Record/Request/Page  [ Next ]
      Exit Loop If [ Nut_calcs::__IDnuts=52 ]

       

       

      working well, but on adding a new IO record, the scipt blanks all fields except the initial: Set Field [ Nut_calcs::_IDIO; $nutcalc_ioID ].


      Relationships:

      Patient::IO_n = IO 2::__ID

      Patients < Calc < IO < Nut_calcs > Nut_eqs.

       

      I puzzled the first 'Set Field' works, but suddenly none of the others do.

        • 1. Re: Reset field and update evaluation2
          electon

          I've read the other post and must say it is difficult to follow.


          Set Field [ Patient::IO_n; IO 2::__ID ]

          You're on the Patient layout? How dow you get IO 2::__ID ? Via the Calc relationship?

          How / what for will you set that if they are the relationship?


          Set Variable [ $nutcalc_ioID; Value:Patient::IO_n ]

          Commit Records/Requests [ No dialog ]

          Go to Layout [ “Nut_calcs” (Nut_calcs) ]

          Go to Record/Request/Page [ First ]

          Loop

           

          Do you always update the same records in the Nut_calcs table?

          Shouldn't you be creating new records that link to the parent IO2::__ID ???


          Set Field [ Nut_calcs::_IDIO; $nutcalc_ioID ]

          Set Field [ Nut_calcs::Nut; Evaluate(Nut_eqs::Nut) ]

          + some other fields

          Go to Record/Request/Page  [ Next ]


          Again you exit loop after 52 records are updated, why???

          Exit Loop If [ Nut_calcs::__IDnuts=52 ]


          One reason i can think of is Nut_calcs is a fixed table and the definitions come from Nut_eqs table that has calculations defined as text. Is that why you use Evaluate?

          I see the reason for flexibility but this is the part we don't see and it will heavily depend on the context.


          I'm guessing you're not doing something in IO table to link everything together.


          • 2. Re: Reset field and update evaluation2
            tays01s

            Apologies for any lack of clarity. Answering your points in turn:

            1. Yes on Patient layout. There is a Patient::Calc_n to IO 2::_CalcID relationship. Patient::Calc_n is set by the New Calc script.

             

            2. Nut_calcs table: Yes, updated. There could 10 fields and 51 records in each per IO record. I was concerned at how fast the DB could grow, but perhaps I'm wrong to worry?

             

            3. Exit after 52: There are 51 records (calculations) in the Nut_eqs table. Once each of these has been run through, it needs to exit.

             

            4. Reasons:

            a. Yes calc definitions come from Nut_eqs and yes that's why I'm using Evaluate. As you say using Nut_eqs as library of calcs is very flexible and needs to be because of the non-standard calcs that need to be run through.

             

            Query: I'll check IO linkages and try creating new Nut_calc records. Might it be worth having Nut_calc fields displayed in an IO 2 portal on the Patient layout to maintain context?