Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleCreate a filter function in filters.lua

Notice we are brought to an empty filters.lua script in the project tree. Lets add our filtering logic:

First, create your a filter function Block statements and pass patient as the parameter.

Code Block
languagelua
function filter(patient)
   
end 

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

Navigate back to the filter.lua by using the Annotation Windows, notice there is now an annotation window block we can use to add the rest of the logic.

Expand
titleIn our filter function, first split the patient contact email to isolate the email domain name

Using String:split(), we can split the email on “@“ and get the domain name.

Try this code and take a look at your annotations to see the result:

Code Block
languagelua
local email = patient.contact.email
local domain = email:split("@")[2]
trace(domain)
if domain == 'interfaceware.com' then return true else return false end

:

Image Added

Now lets go back to main and change the way we are calling our filter function to address the boolean values (true/false) being returned.

Expand
titleUse an if statement to test if an email domain does not equal to "interfaceware.com"

Using if statements, we can test conditions to be false and filter out data we are not interested in processing.

Code Block
languagelua

...