Salary component based on condition related to other doctype

Hi everyone
Is there a way to link a salary component to a condition related to other doctype ?
For example in a clinic i need to add fixed daily bonus to the salary only in days having certain amount of patients or similar scenario …

Any help would be appreciated
Thanks in advance

Salary Component only reads all fields from only two doctypes (employee, salary structure assignment)