Lua Scripting Accession Routing match

Wondering if someone can share a example of a lua script for auto-routing that matches tag AccessionNumber? I have a need to route to a destination based in the starting sequence of the accession#. Example, 90MG***** routed to destination1, 80MG***** routed to destination2.

If you use this type of If statements you can define where things are routed:
https://www.lua.org/pil/4.3.1.html

From there, if you follow the Orthanc scripting manual and you should be good to do. A quick example using sendtopeer:

if origin[‘CalledAet’] == “CURRENT” then
PrintRecursive(“Current " … tags[‘Modality’] … " Image Has Arrived. Forwarding”)
SendToPeer(jpeg2kInstance[‘ID’], ‘PEER1’)
else
PrintRecursive(“Prior " … tags[‘Modality’] … " Image Has Arrived. Forwarding”)
SendToPeer(jpeg2kInstance[‘ID’], ‘PEER2’)
end