[SOLVED] Promt user to set variable

Hello guys, thank you in advance for your help. I am creating a format for recording procedures in medical records. Obviously, I am terrible at this. My intention is to create a user input where the user enters the tooth number, the surface (so far, so good) and whether or not anesthesia was applied. From there, I want to insert the text. The problem is that anesthesia can have several types: alveolar anterior, media, post, etc. I would like that when the user enters, for example: Anesthesia = Alveolar anterior, the following text is inserted: ANESTHESIA OF LIDOCAINE 2% WITH EPINEPHRINE 1:80,000, WITH THE TECHNIQUE "ALVEOLAR ANTERIOR". I know that this can be done with the If This.. function, but I was wondering if there is a more efficient way to do it.

I asked Bard for help and he gave me some code that is similar to this. However, I don't know how to use it in my application.

function insertText(anesthesiaType) {
switch (anesthesiaType) {
case "alveolar anterior":
return "ANESTHESIA OF LIDOCAINE 2% WITH EPINEPHRINE 1:80,000, WITH THE TECHNIQUE "ALVEOLAR ANTERIOR"";
case "alveolar media":
return "ANESTHESIA OF LIDOCAINE 2% WITH EPINEPHRINE 1:80,000, WITH THE TECHNIQUE "ALVEOLAR MEDIA"";
case "alveolar posterior":
return "ANESTHESIA OF LIDOCAINE 2% WITH EPINEPHRINE 1:80,000, WITH THE TECHNIQUE "ALVEOLAR POSTERIOR"";
default:
return "INVALID ANESTHESIA TYPE";
}
}

// Use the function
const anesthesiaType = "alveolar anterior";
const text = insertText(anesthesiaType);

Is this the better way to do?

If it were me, I'd use a Case statement between the input and the output:

CASE %Variable%Anestesia% is Alveolar anterior:
  Set variable expanded_text to: "ANESTHESIA OF LIDOCAINE 2% WITH EPINEPHRINE 1:80,000, WITH THE TECHNIQUE "ALVEOLAR ANTERIOR"

CASE %Variable%Anestesia% is Alveolar medium:
  Set variable expanded_text to something else

CASE etc...

Then in the "Insert text by typing" block, replace %Variable%Anestesia% with %Variable_expanded_text% (or whatever you named it).

-rob.

1 Like