Jump to content

Checkbox sets and looping IF statements


This topic is 2690 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

I'm a dentist. I'm trying to generate written treatment plans for patients to have as a treatment estimate and for our records.

People have 32 teeth, therefore I have setup a field (ToothNumber), displayed as a checkbox set utilizing a value list = 1 through 32. When I click my CROWN script button, it opens a selection window wherein I choose the tooth number from said field (1-32), the material the crown is to be made of (porcelain, gold, zirconia, etc.), whether I want to use lab-processed temporary crowns, and so forth. 

If I have only one tooth number checked and run through my nested IF statements, which looks up the official description for the type of crown, the ADA code, the fee, the time required, etc., it all works fine. If I have more than one tooth number selected in the checkbox set, it only returns one line for the first tooth checked. 

The IF statement looks something like: If TOOTH NUMBER = 2 and CROWN MATERIAL = porcelain and LAB TEMP CROWN = "Yes" then it adds a line on the treatment items table which looks up appropriate description, ADA code and fee, so the patient has a copy and so do we. And we're both on the same page regarding what they want to accomplish. 

Am I using the wrong method for displaying and relating my selections? If so, what's the best way to accomplish this. Also, I want to avoid repeating the same sequence for each tooth number, i.e., I'd rather LOOP to advance through tooth 1 through 32. Any ideas? 

Link to comment
Share on other sites

OK, a checkbox set is a visual display of a list of checked items. So, if you checked tooth 3, 7, 10 it is stored as

3
7
10

So your looping script needs to run for each of these listed values. You use the GetValue function to grab each of them.

Pseudo-code

Set Variable [$list; Table::ToothList ]
Set Variable [$count; ValueCount ( $list)]
Set Variable $i //Counter for the loop iterations
Loop
  Set Variable [$whichTooth; GetValue [ $list, $i ]
   Perform Script [ Your script, passing the value of $whichTooth ]
  Set Variable [$i; $i + 1 ]
  Exit Loop If [ $i > $ count]
Loop

So it runs the script for each checked tooth...

Link to comment
Share on other sites

  • Newbies

Thanks, Webko. I'll give it a try. 

My wife and I come to your country once or twice a year, mostly Melbourne but also Brisbane and Sydney. It's always a treat to be there, even in winter, getting us out of the oppressive Florida heat and humidity. 

Link to comment
Share on other sites

  • Newbies

All right. I tried a number of iterations of your suggested script, but can't get the treatment line items which are tooth-number dependent to display on the treatment list. I'm attaching screen shots of both the Loop section with preceding Set Variable steps, and the window where the teeth and materials are selected. Here's how I interpreted it:

(I trust you'll let me know when the meter is running and I owe you a fee for helping me.)

Screen Shot 2016-11-24 at 10.16.56 PM.png

Screen Shot 2016-11-24 at 10.18.37 PM.png

Link to comment
Share on other sites

Off top of my head - $count should be a count of how many items are in the $list - so, as I wrote it, not all the possible values

$whichTooth will be set to the current value depending on the position in the list (determined by $i) - so no need for the If statement

Have a look at those first - I'm about to finish up for the week, so if you're still having issues Sunday your time, post a zipped copy of the file here for people to look at...

Link to comment
Share on other sites

  • 2 weeks later...

This topic is 2690 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.