...
Expand | ||
---|---|---|
| ||
Now we are in the Translator! Every Translator component contains a Main.lua module with a main function that is called each time a message is received or on a configured poll time. Notice we can see our sample data (variable named Data) passed to main functionby looking at the Annotation Windows. If we click on the sample data in the annotations, we can view it using The string viewing window. |
Expand | |||||
---|---|---|---|---|---|
| |||||
In main, parse the JSON sample data by passing Data.
JSON objects are parsed into Lua tables as dictionaries with key-value pairs. You can see this clearly in the Annotation Window. |
...
Expand | |||||
---|---|---|---|---|---|
| |||||
Notice we are brought to an empty filters.lua script in the project tree. Lets add our filtering logic: First, create your filter function Block statements and pass patient as the parameter.
Then go into main and call your filter function, passing your parsed patient JSON as the expected parameter. Notice after calling our filter function, when we go back into filter.lua, there is now an annotation window we can use to add the rest of the logic. |
...
Expand | ||
---|---|---|
| ||
By switching which Sample Data is being passed to main, we can see the results and test how our filter function works, by using the annotations. Switch to the second sample data to see the sample message fail the condition and return false. |
Expand | |||||
---|---|---|---|---|---|
| |||||
Now that the annotations are active for the failed scenario, we can leverage them to add Custom Logging to add more visibility into the logs. For example,
You’re done the filter! Don’t forget to Commit and Push Changes to Git. |