Using the repeat function to find an item in a list

{note}{formtext: name=BCBS prefix; default=}{digit=upper(split({=`BCBS prefix`}, ""))}

{hmo=["ZGN","ZGI","ZGZ","T2G","VEX","VEU","VEN"]}

{if:`bcbs prefix`=""}
Please enter the BCBS prefix you would like to test for HMO. Just enter the first three letters and type in uppercase <3
{repeat: for item in hmo}
{if: `bcbs prefix`=item}
This plan is an HMO plan. Please add this patient onto the auth list now. Call for the referral ASAP. Thank you!

{endif}

{endrepeat}
{else: trim=yes}
This plan is not an HMO.
{endif}

{endnote: trim=yes}

I'm trying to figure out why the repeat function is not working here. Can TextBlaze iterate in a list like this? Thank you!

EDIT: for some reason when I copied this over, all these red errors appeared. In my textblaze, I have no errors, but the output is "This plan is not an HMO." no matter what the user inputs. I posted the snippet here, where the error does not exist: Copy of Snippet "Hmo checker" Thanks again.

Hi @novemberrain, I just moved endif to get it worked.
Is this similar you are looking for? If you can explain me what you are exactly looking for, I can propose a better solution.

{note}{formtext: name=BCBS prefix; default=}{digit=upper(split({=`BCBS prefix`}, ""))}

{hmo=["ZGN","ZGI","ZGZ","T2G","VEX","VEU","VEN"]}

{if: `bcbs prefix`=""}
Please enter the BCBS prefix you would like to test for HMO. Just enter the first three letters and type in uppercase <3
{else}
{repeat: for item in hmo}
{=item}
{if: `bcbs prefix`=item}
This plan is an HMO plan. Please add this patient onto the auth list now. Call for the referral ASAP. Thank you!

{else: trim=yes}
This plan is not an HMO.
{endif}
{endrepeat}
{endif}
{endnote: trim=yes}

I tweaked things a little bit from what you just posted and got this. It almost works like the way I would like it to. If any prefix is entered that is in the list "hmo", it outputs the string: "This plan is an HMO plan. Please add this patient onto the auth list now. Call for the referral ASAP. Thank you!". If the prefix is anything that is not in the string it outputs nothing. I would like for it to output the string "This is not an HMO." when that happens, any tips?

{note}{formtext: name=BCBS prefix; default=}

{digit=upper(split({=`bcbs prefix`}, ""))}

{hmo=["ZGN","ZGI","ZGZ","T2G","VEX","VEU","VEN"]}

{if: `bcbs prefix`=""}
Please enter the BCBS prefix you would like to test for HMO. Just enter the first three letters and type in uppercase <3
{else: trim=yes}
{repeat: for item in hmo}
{if:`bcbs prefix`=item}
This plan is an HMO plan. Please add this patient onto the auth list now. Call for the referral ASAP. Thank you!
{endif: trim=yes}
{endrepeat}
{endif}
{endnote: trim=yes}

EDIT: I'm getting that weird error again :Invalid formula for {if} – unexpected β€œp” in β€œβ€¦s pre…”

Not sure why that happens when I copy paste over from the application.

@novemberrain backticks sometimes get removed when you copy the snippet here. I've fixed it in yours.

I created a version of your snippet using:

  1. The left() function which allows the user to type any BCBS
  2. The includes() function which checks if an item is in a list

Let me know if this works

{note}
{formtext: name=BCBS prefix; default=}

{prefix=upper(left({=`BCBS prefix`}, 3))}

{hmo=["ZGN","ZGI","ZGZ","T2G","VEX","VEU","VEN"]}

{if: `bcbs prefix`=""; trim=left}
Please enter the BCBS prefix you would like to test for HMO. Just enter the first three letters and type in uppercase <3
{elseif: includes(hmo, prefix); trim=left}
This plan is an HMO plan. Please add this patient onto the auth list now. Call for the referral ASAP. Thank you!
{endif: trim=yes}
{endnote: trim=yes}

1 Like

This works great, thank you so much!