Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
7

PDF Script for a popup

Participant ,
Mar 05, 2024 Mar 05, 2024

Hi.  I have a PDF file that contains a really long script for a popup.  I know there's an easier way to write the script, but I'm just not sure how to write the simplified script.  If you press the buttons by the names, it gives you a popup of 2-3 items.  It works perfectly until I try to utilize the "Office Use Only" box at the bottom right of the pdf.  If info is added into the "Office Use Only" box for a given row at the top, it is supposed to give a different list of items in the popup when the button next to the name is pressed.   

 

Can you help with a simplier way to right the script?  I think I can't figure out the solution because the script is so, long?

 

 

TOPICS
JavaScript , PDF , PDF forms
17.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Mar 05, 2024 Mar 05, 2024

For example, this part:

 

else if(units > 0 && insure == "CareSource" && im1 != "Off" && row6 == "2" && rx6 != "")
    app.alert(
    "Patient: " + name + "\n D9248 1 qty $125 \n D9630 1 qty $100"
);

else if(units > 0 && insure == "DentaQuest" && im1 != "Off" && row6 == "2" && rx6 != "")
    app.alert( 
    "Patient: " + name + "\n D9248 1 qty $125 \n D9630 1 qty $100"
);

else if(units > 0 && insure == "Envolve" && im1 != "Off" && row6 == "2" && rx6 != "")
    app.alert(
     "Patient: " + name + "\n D9248 1 qty $125 \n D9630 1 qty $100"
);

else if(units > 0 && insure == "GHP" && im1 != "Off" && row6 == "2" && rx6 != "")
    app.alert(
     "Patient: " + name + "\n D9248 1 qty $125 \n D9630 1 qty $100"
);

 

Can be shortened like this:

 

else if(units > 0 && im1 != "Off" && row6 == "2" && rx6 != "" && (insure == "CareSource" || insure == "DentaQuest" || insure == "Envolve" || insure == "GHP")) {
    app.alert("Patient: " + name + "\n D9248 1 qty $125 \n D9630 1 qty $100");
}

 

When you have the same alert for multiple conditions and mostly all conditions are the same except 'insure' in this case, put it inside parentheses and use || (or).

 

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 05, 2024 Mar 05, 2024

For example, this part:

 

else if(units > 0 && insure == "CareSource" && im1 != "Off" && row6 == "2" && rx6 != "")
    app.alert(
    "Patient: " + name + "\n D9248 1 qty $125 \n D9630 1 qty $100"
);

else if(units > 0 && insure == "DentaQuest" && im1 != "Off" && row6 == "2" && rx6 != "")
    app.alert( 
    "Patient: " + name + "\n D9248 1 qty $125 \n D9630 1 qty $100"
);

else if(units > 0 && insure == "Envolve" && im1 != "Off" && row6 == "2" && rx6 != "")
    app.alert(
     "Patient: " + name + "\n D9248 1 qty $125 \n D9630 1 qty $100"
);

else if(units > 0 && insure == "GHP" && im1 != "Off" && row6 == "2" && rx6 != "")
    app.alert(
     "Patient: " + name + "\n D9248 1 qty $125 \n D9630 1 qty $100"
);

 

Can be shortened like this:

 

else if(units > 0 && im1 != "Off" && row6 == "2" && rx6 != "" && (insure == "CareSource" || insure == "DentaQuest" || insure == "Envolve" || insure == "GHP")) {
    app.alert("Patient: " + name + "\n D9248 1 qty $125 \n D9630 1 qty $100");
}

 

When you have the same alert for multiple conditions and mostly all conditions are the same except 'insure' in this case, put it inside parentheses and use || (or).

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 06, 2024 Mar 06, 2024

That helped.  Thank you!  I was able to figure the other solution with that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 06, 2024 Mar 06, 2024
LATEST

Okay, so I still seem to be having a problem.  I simplified the code:

var name = this.getField("Name.1").value;
var insure = this.getField("ins.1").value;
var units = this.getField("unitcal1").value;
var emerg = this.getField("Box1").value;
var row1 = this.getField("row1").value;
var row2 = this.getField("row2").value;
var row3 = this.getField("row3").value;
var row4 = this.getField("row4").value;
var row5 = this.getField("row5").value;
var row6 = this.getField("row6").value;
var im1 = this.getField("imo1").value;
var im2 = this.getField("imo2").value;
var Im3 = this.getField("imo3").value;
var Im4 = this.getField("imo4").value;
var Im5 = this.getField("imo5").value;
var Im6 = this.getField("imo6").value;
var rx1 = this.getField("rxmath1").value;
var rx2 = this.getField("rxmath2").value;
var rx3 = this.getField("rxmath3").value;
var rx4 = this.getField("rxmath4").value;
var rx5 = this.getField("rxmath5").value;
var rx6 = this.getField("rxmath6").value;


//IM off, Rx on, row on//

if(units > 0 && (insure == "CareSource" || insure == "DentaQuest" || insure == "Envolve") && (row1 == "1" && rx1 != "" && im1 == "Off" || row2 == "1" && rx2 != "" && im2 == "Off" || row3 == "1" && rx3 != "" && im3 == "Off" || row4 == "1" && rx4 != "" && im4 == "Off" || row5 == "1" && rx5 != "" && im5 == "Off" || row6 == "1"&& rx6 != ""&& im6 == "Off"))
    app.alert(emerg != "Off" ?
    "Patient: " + name + "\n D9239  1 qty $125 \n D9243 " + (units - 1) + " qty $" + ((units - 1)*125) + "\n D9610 1 qty $100 \n D9630 1 qty $100 \n Remarks: Emergency due to 'see note' " :
    "Patient: " + name + "\n D9239  1 qty $125 \n D9243 " + (units - 1) + " qty $" + ((units - 1)*125) + "\n D9610 1 qty $100 \n D9630 1 qty $100"
);


else if(units > 0 && insure == "GHP" && (row1 == "1" && rx1 != "" && im1 == "Off" || row2 == "1" && rx2 != "" && im2 == "Off" || row3 == "1" && rx3 != "" && im3 == "Off" || row4 == "1" && rx4 != "" && im4 == "Off" || row5 == "1" && rx5 != "" && im5 == "Off" || row6 == "1"&& rx6 != ""&& im6 == "Off"))
    app.alert(emerg != "Off" ?
    "Patient: " + name + "\n D9243 " + (units) + " qty $" + ((units)*125) + "\n 96372 1 qty $100":
    "Patient: " + name + "\n D9243 " + (units) + " qty $" + ((units)*125) + "\n 96372 1 qty $100"
);

//IM on, Rx off, row on//

else if(units > 0 && (insure == "CareSource" || insure == "DentaQuest" || insure == "Envolve") && (row1 == "1" && im1 != "Off"&& rx1 == "" || row2 == "1" && im2 != "Off"&& rx2 == "" || row3 == "1" && im3 != "Off"&& rx3 == "" || row4 == "1" && im4 != "Off"&& rx4 == "" || row5 == "1" && im5 != "Off"&& rx5 == "" || row6 == "1"&& im6 != "Off"&& rx6 == ""))
   app.alert(emerg != "Off" ?
    "Patient: " + name + "\n D9248  1 qty $125 \n Remarks: Emergency due to 'see note' " :
    "Patient: " + name + "\n D9248  1 qty $125"
);    

else if(units > 0 && insure == "GHP" && (row1 == "1" && im1 != "Off"&& rx1 == "" || row2 == "1" && im2 != "Off"&& rx2 == "" || row3 == "1" && im3 != "Off"&& rx3 == "" || row4 == "1" && im4 != "Off"&& rx4 == "" || row5 == "1" && im5 != "Off"&& rx5 == "" || row6 == "1"&& im6 != "Off"&& rx6 == ""))
    app.alert(emerg != "Off" ?
    "Patient: " + name + "\n D9248  1 qty $125" :
    "Patient: " + name + "\n D9248  1 qty $125"
);   

//IM on, Rx on, row on//

else if(units > 0 && (insure == "CareSource" || insure == "DentaQuest" || insure == "Envolve") && (row1 == "1" && im1 != "Off" && rx1 != "" || row2 == "1" && im2 != "Off" && rx2 != "" || row3 == "1" && im3 != "Off" && rx3 != "" || row4 == "1" && im4 != "Off" && rx4 != "" || row5 == "1" && im5 != "Off" && rx5 != "" || row6 == "1" && im6 != "Off" && rx6 != ""))
  app.alert(emerg != "Off" ?
    "Patient: " + name + "\n D9248  1 qty $125 \n D9630 1 qty $100 \n Remarks: Emergency due to 'see note' " :
    "Patient: " + name + "\n D9248  1 qty $125 \n D9630 1 qty $100"
);     

else if(units > 0 && insure == "GHP" && (row1 == "1" && im1 != "Off" && rx1 != "" || row2 == "1" && im2 != "Off" && rx2 != "" || row3 == "1" && im3 != "Off" && rx3 != "" || row4 == "1" && im4 != "Off" && rx4 != "" || row5 == "1" && im5 != "Off" && rx5 != "" || row6 == "1" && im6 != "Off" && rx6 != ""))
 app.alert(emerg != "Off" ?
    "Patient: " + name + "\n D9248  1 qty $125 \n D9630 1 qty $100" :
    "Patient: " + name + "\n D9248  1 qty $125 \n D9630 1 qty $100"
);

//IM off, Rx off, row off//

else if(units > 0 && (insure == "CareSource" || insure == "DentaQuest" || insure == "Envolve"))
    app.alert(emerg != "Off" ?
    "Patient: " + name + "\n D9239  1 qty $125 \n D9243 " + (units - 1) + " qty $" + ((units - 1)*125) + "\n D9610 1 qty $100 \n Remarks: Emergency due to 'see note' " :
    "Patient: " + name + "\n D9239  1 qty $125 \n D9243 " + (units - 1) + " qty $" + ((units - 1)*125) + "\n D9610 1 qty $100"
);

else if(units > 0 && insure == "GHP")
    app.alert(emerg != "Off" ?
    "Patient: " + name + "\n D9243 " + (units) + " qty $" + ((units)*125) + "\n 96372 1 qty $100":
    "Patient: " + name + "\n D9243 " + (units) + " qty $" + ((units)*125) + "\n 96372 1 qty $100"
);

It works unless I try to use "Office Use Only" rows 3, 4, 5, and 6.  "Office Use Only" rows 1 and 2 work fine.  Is there another way to simplify things to figure out why only those 4 rows in that box are giving me a problem?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines