4 Replies Latest reply on Jun 24, 2014 2:02 PM by philmodjunk

    Using "OR" operator with the "case" function

    BuchiOgbuagu

      Title

      Using "OR" operator with the "case" function

      Post

           Hi all,

            

           I am trying to create a new calculation field using information from an existing field but every time I input the calculation, it comes back blank.

           Any number of options can be checked off in the check box set but I would like to use only a few of them for the calculation.The calculation I have tried is below;

           Case (
           Type of Anesthesia Performed = "General Anesthesia";"GA" or
           Type of Anesthesia Performed = "Inhalational (+/- intravenous)"; "GA" or
           Type of Anesthesia Performed = "TIVA"; "GA";
           Type of Anesthesia Performed = "Regional Anesthesia"; "Regional";
           Type of Anesthesia Performed = "Local Anesthesia"; "Regional"
           )
            
           Any ideas on how to get around this?

            

        • 1. Re: Using "OR" operator with the "case" function
          philmodjunk

               Case functions use this syntax:

               Case ( Boolean expression 1 ; result expression 1 ;
                          Boolean expression 2 ; result expression 2 ;
                          // and so forth....
                          Other result expression
                         )

               A case function evaluates each Boolean expression and returns the value of the corresponding result expression of the first Boolean expression to evaluate as True. The Other result is returned if all of the Boolean Expressions evaluate as False.

               But you have included the OR operator as part of the first result expression. And that makes no sense.

               Case (
                  Type of Anesthesia Performed = "General Anesthesia";"GA" or Type of Anesthesia Performed = "Inhalational (+/- intravenous)";
                  "GA" or Type of Anesthesia Performed = "TIVA"; "GA";
                  Type of Anesthesia Performed = "Regional Anesthesia"; "Regional";
                  Type of Anesthesia Performed = "Local Anesthesia"; "Regional"
                  )
                
               My best guess as to what you need:
                    Case (
                    Type of Anesthesia Performed = "General Anesthesia";"GA" ;
                    Type of Anesthesia Performed = "Inhalational (+/- intravenous)"; "GA" ;
                    Type of Anesthesia Performed = "TIVA"; "GA";
                    Type of Anesthesia Performed = "Regional Anesthesia"; "Regional";
                    Type of Anesthesia Performed = "Local Anesthesia"; "Regional"
                    )

                

          • 2. Re: Using "OR" operator with the "case" function
            appt

                 Replace or with ;  ( a semi colon)

                  

            • 3. Re: Using "OR" operator with the "case" function
              BuchiOgbuagu

                   Hi  PhilModJunk,

                    

              Thanks so much for the response but I had tried that before but still came up with a blank.

              Just in case this may help clarify things, here is a breakdown of the checkbox options for the field in question;

              Types of Anesthesia Performed (check all that apply)

              1. General Anesthesia

              2. Total Intravenous Anesthesia

              3. Inhalational (+/- intravenous)

                 - Mask

                - Oral Airway

                - Endotracheal Tube (ETT)

               - Laryngeal mask Airway

              4. Regional Anesthesia 

                      - Spinal

                - Epidural

                - Nerve Block

              5. Regional Anesthesia Changed to GA

              6. Local Anesthesia

              7. Monitored Anesthesia Care

                    

                    

              Hope this helps

              • 4. Re: Using "OR" operator with the "case" function
                philmodjunk

                     Does this mean that you have one field formatted with a value list of multiple check box values?

                     That would definitely explain why this does not work the way that you expected.

                     Let's say you have a field formatted with check boxes with the following value list: A, B, C. Three checkboxes on one field.

                     If you click the check box for A, then the check box for C, you see both check boxes selected. but if you make a copy of this field and remove the checkboxes format to return it to edit box format, you'll see that you have both values in the field on separate lines as they are separated by a return character.

                     If you clear those choices, then click C then A, even though the same checkboxes display as selected, you'll see C on line 1 and A on line 2. And in an calculation such as your case function a  field with "A<return>C" does not equal "C<return>A".

                     Here's how to test to see if the check box for A has been selected in our A, B, C value list example:

                     Not Isempty ( Filtervalues ( CheckboxField ; "A" ) )

                     will be True if "A" has been selected.

                     You can use this type of expression in the Boolean expressions of your Case function, but keep in mind that only the result expression of the first Boolean to evaluate as True will be evaluated and returned so I am not sure even that will work for you in this situation.