HOW TO SEARCH IF A STRING EXISTS IN A LOOKUP TABLE
Hello,
I am quite new to the InterSystems world. I have one of my OBX 5 fields having this value "blood work was done<>tested positive for anemia<>tested negative for hepatitis". I have a lookup table "AnemiaResults" with a key of TESTED POSITIVE FOR ANEMIA. My issue is that since OBX 5 has other characters/text (and OBX is a repeating segment) , I am unable to use the Exists function. Any idea how to tackle this? Any assistance will be greatly appreciated.
Product version: IRIS 2021.2
Hi @Christine Nyamu
Use $Piece function to get the value of a delimited string. In you specific case:
Set value = $Piece(obxValue, "<>", 2)
I assumed that the variable obxValue was set before in the code.
Note if the in the obx segment the value change the order like, "TESTED POSITIVE FOR ANEMIA<>BLOOD WORK WAS DONE<>TESTED NEGATIVE FOR HEPATITIS", the above sample code will fail
Thanks for your reply. Will try it out
Edited to add:
Would Set value = $Piece(obxValue, "<>", *) work?
The challenge is that the text does not follow any particular order :-(
Hi Christine,
Please consider if the following snippet may be helpful.
Includes some common checks to prevent invalid lookup
Thanks. Will have a look
Thanks for your reply Alex Woodhead. You seem to offer a very complete solution and handle some special cases, such as whitespace removal and case insensitive searches.
Hi @Alex Woodhead
At which point do we actually specify the lookup table we are searching against in the function? In my case, the table is AnemiaResults
In Routing Rule context, the newly projected function ExistsAny is applied.
The first argument is the LookupTable name from method signature.
An example expression: