View Single Post
 
Old 05-21-2018, 03:20 PM
mtracy16 mtracy16 is offline Windows 10 Office 2016
Novice
 
Join Date: May 2018
Location: Atlanta, GA
Posts: 2
mtracy16 is on a distinguished road
Default Conditional checkbox mailmerge: coding "or" statements within IF statements

I am in the process of updating a form containing several checkbox mailmerge fields to reflect changes in testing practices for microbial specimens. The mailmerge document is saved as a word 1997-2003 document. The data source is an excel 1997-2003 workbook.

Fields relevant to my problem are:
LABTEST1
DISEASE

Possible outcomes for these two character variables are:
LABTEST1 = "Culture" or "Pcr"
DISEASE = "Campylobacter" "STEC" "Salmonella" "Shigella" "Yersinia" "Listeria" or "Vibrio"

Specimens that test positive by "Culture" can be categorized as an Enteric Isolate or as Special Bacteriology depending on the DISEASE type. Specimens that test positive by "Pcr" are all categorized as Clinical Specimens regardless of DISEASE type.

I was able to write the code for the "Pcr" specimens easily as they all are categorized as Clinical Specimens. The code below successfully creates a check box next to the category Clinical Specimen for "Pcr" positive specimens.
{IF {MERGEFIELD LABTEST1}= "Pcr" þo}

I also was able to write code for the subfield checkboxes for both "Pcr" specimens & "Culture" specimens that specify the "DISEASE" (if labtest1 AND disease then check then check the box). For example, specimens that tested positive for "Campylobacter" by "Culture" successfully insert a checkbox with the following conditional coding:
{IF {MERGEFIELD LABTEST1}="Culture" {IF {MERGEFIELD DISEASE}="Campylobacter" þo} o }

Similarly, this same coding also works to specify "DISEASE" for "Pcr" specimens. The only difference is that the "LABTEST1" field is switched from "Culture" to "Pcr". Thus, specimens that tested positive for "Campylobacter" by "Pcr" successfully insert a checkbox with the following code:
{IF {MERGEFIELD LABTEST1}="Pcr" {IF {MERGEFIELD DISEASE}="Campylobacter" þo} o }

Here is where the problem starts I am having trouble writing code to distinguish between two different categories for culture specimens. Specimens that test positive for one of the above "DISEASE" options via "Culture" either require further testing as an Enteric Isolate (this applies for "Campylobacter" "STEC" "Salmonella" "Shigella" "Yersinia") or they require further testing as Special Bacteriology (this applies for "Listeria" "Vibrio"). I have attached a screenshot of the form so you can view how these are grouped Screenshot of mailmerge form.JPG.

Basically, to check the Enteric Isolate box I need to write a code that says IF LABTEST1= "Culture" AND IF DISEASE= "Campylobacter" OR "STEC" OR "Salmonella" OR "Shigella" OR "Yersinia" THEN check the Enteric Isolate box. Similarly, to check the Special Bacteriology box I need to write a code that says IF LABTEST1= "Culture" AND IF DISEASE= Listeria" OR "Vibrio" THEN check the Special Bacteriology box.

Since the Special Bacteriology checkbox is used for fewer DISEASE types, I started trying out different iterations of conditional codes with or statements for the Special Bacteriology field. I haven't had any success so for, but the closest I have gotten is with the following code:

{IF {MERGEFIELD LABTEST1}="Culture" {{IF {MERGEFIELD DISEASE}="Yersinia"}OR{IF {MERGEFIELD DISEASE}="Vibrio"} þo} o}

Please send me your help & recommendations! I know there must be a way to do this, I just haven't cracked it yet. Thanks for your help!
Reply With Quote