6 Replies Latest reply on Mar 25, 2011 11:37 AM by gkaiseril

    Calculation script help - unfortunate side effect of limited programming knowledge


      I had plenty of great help before, so im trying to get one big problem fixed with some help again.  Thanks in advance.

      I guess I cant post my PDF file, but I can email if anyone can help.


      Basically, I have created an order for chemotherapy.  The user enters the height and weight, which then is used for the BSA function


      var1 = this.getField("height").value;
      var2 = this.getField("weight").value;

      event.value = 0.007184 * (Math.pow(var1, 0.725) * Math.pow(var2, 0.425));

      Then using the BSA the drug doses are auto-calculated using the formula before.  We wanted the default dose (in this case 750 mg) to show up, but next to it is drug1 which the user can change this to say 500.  In that case 500 would over-ride and the end result would be a change in dose.  My problem that I am trying to figure out a fix for is in the way it was created.  Drug1 defaults at 0.


      What I would like to do is have a way so that the user can enter 0 in the drug1 blank so that the final dose is also 0.  Otherwise if the user enters 0 right now it gives the full dose as a result.  Or if there is another way around this that anyone can think of I would greatly appreciate the help.  It would be nice if acrobat would let you change a result after a calculation has been performed, but I dont think that is possible.



      // field name for override
      var Field_Name = 'drug1';
      // default dosage rate
      var Drug_1_Dose_Rate = 750;
      // see if we need to override
      if (Number(this.getField(Field_Name).value) != 0) {
      // Drug1 field not empty so use the entered value
      Drug_1_Dose_Rate = Number(this.getField(Field_Name).value);
      } // end if not null
      // compute the dosage using the required rate
      event.value = Drug_1_Dose_Rate * this.getField('BSA').value;

      Thanks, Chris