You can do this with dynroutes using the Asterisk REGEX function. Using Asterisk Variable from dynroutes with an expression like:
${REGEX("^.*([mM]edical|[Ll]egal).*$" ${CALLERID(name)})}
The above expression will catch inbound callers with CID names that have the words Medical, medical, Legal or legal and return a 0 or 1 based on whether there’s a match. You can use the 0 or 1 to branch the call in dynroutes.
Match returns 1:
Family Medical Center
family legal center
No match returns 0:
FAMILY MEDICAL CENTER
family center