AnsweredAssumed Answered

Replace field contents

Question asked by tays01s on Sep 1, 2017
Latest reply on Sep 7, 2017 by tays01s

1. I have a script below that generates/replaces 51 records in 'Nut_Calcs' table by evaluating equations from 'Nut_eqs' table related by Nut_Calcs::_Nut_eqs_ID = Nut_eqs::__ID.

2. Each set of Nut_Calcs records is related to IO: Nut_Calcs_IOn:: _IOuuID = IOn::__uuID.

3. The 'IO' record to be updated is set from a portal 'IO_all_for_pt' on the Patient layout


2 problems occur:

a) Once I have run the script several times and there are a few 100 Nut_Calcs records, I see an info box popping up “NNN remaining records to update” meaning that the script is going through ALL 'Nut_Calcs' records, not just when Nut_Calcs_IOn:: _IOuuID = Ion::__uuID. But, the script does NOT evaluate (ie. do the calcs). It just spends time going through all the records.

 

b) Without an obvious pattern, the whole set of 51 Nut_Calcs records gets evaluated based on the 51st Nut_eqs equation, presumably because I find the Nut_Calcs::_Nut_eqs_ID is set to '51' for the whole set of 51 records.


Set Field [ Patient::IO_n; IO_all_for_pt::__uuID ]
Set Field [ Patient::Calc_n; IO_all_for_pt::_CalcUUID ]
Loop

Exit Loop If [ Let($i = $i +1;$i = 52) ] New Record/Request
Set Field
[ Nut_calcs::_Nut_eqsID; $i ]

End Loop
Commit Records/Requests
[ No dialog ]
Replace Field Contents [ Nut_calcs_IOn::Nut; Replace with calculation: Nut_eqs_IOn::Nut ] [ No dialog ]


Freeze Window

Go to Related Record [ From table: “Nut_calcs_IOn”; Using layout: “Nut_calcs_IOn” (Nut_calcs_IOn) ] [ Show only related records ]

Replace Field Contents [ Nut_calcs_IOn::Unit; Replace with calculation: Nut_eqs_IOn::Unit_part_SI ] [ No dialog ]

Replace Field Contents [ Nut_calcs_IOn::Std_EN; Replace with calculation: Evaluate(Nut_eqs_IOn::StdEN) ] [ No dialog ]

[[[ NB. To reduce complexity I've missed out several field contents update lines and the check to see if updating of existing records was required (this part of the script definitely works). ]]]]


Go to Layout
[ “Patient_U” (Patient) ]

Commit Records/Requests

Outcomes