Skip to main content
Known Participant
May 9, 2024
Answered

Autopopulate text based on another response

  • May 9, 2024
  • 2 replies
  • 1537 views

Is there a way to automatically include a line if text in one field based on the input in a different field. For example I enter a CPT code such as 99204 into one field. This would automatically populate a specific text description in another field such as "New Patient Office Visit" 

i am using pdf forms in this scenario

This topic has been closed for replies.
Correct answer Nesa Nurani

Let's say field where you want to show message is named "Text2" (change this to your actual field name), as 'Validate' script of the field where you input code use this:

var t2 = this.getField("Text2");

if(event.value == "99204")
t2.value = "New Patient Office Visit";

else if(event.value == "123456")
t2.value = "some message";

//keep adding 'else if' for other codes

else
t2.value = "";

2 replies

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
May 9, 2024

Let's say field where you want to show message is named "Text2" (change this to your actual field name), as 'Validate' script of the field where you input code use this:

var t2 = this.getField("Text2");

if(event.value == "99204")
t2.value = "New Patient Office Visit";

else if(event.value == "123456")
t2.value = "some message";

//keep adding 'else if' for other codes

else
t2.value = "";
Known Participant
May 13, 2024

Thank you! Worked perfectly. I have 2 follow-up questions....

1) what if i wanted to also include a third value.

So Field 1 is 99204 which autopopulates Field 2 as New Patient Office Visit (per above code)

PLUS a Field 3 which would autopopulate a number (such as $20).

Field 3 value could be based on Either Field 1 or Field 2.

 

2) Let's say in the above scenario that the value autopopulated in Field 3 (of $20) would actually apply to multiple inputs from Field 1.

So CPT code 99204 and 99203 and 99202 would all autopopulate the SAME value in Field 3 of $20.

 

Thank you!

Nesa Nurani
Community Expert
Community Expert
May 13, 2024

1. Include both field 2 and 3 in curly brackets for same condition like this:

var t2 = this.getField("Text2");
var t3 = this.getField("Text3");

if(event.value == "99204"){
t2.value = "New Patient Office Visit";
t3.value = 20;}

 

2. If you have a lot of same codes that would apply the same amount, it would be easier to put them under one condition, but if those codes don't apply the same message then you will still need to make separate conditions for field 2 and in that case it's better to go with the way I showed you above.

 

If both message and amount would be the same, you could do multiple conditions like this:

var t2 = this.getField("Text2");
var t3 = this.getField("Text3");

if(event.value == "99204" || event.value == "99203" || event.value == "99202"){
t2.value = "New Patient Office Visit";
t3.value = 20;}

Known Participant
May 9, 2024

Also I should add that I do not want either text field to use a drop down menu if possible.