How can we confirm Despatch if its item and its lot number have an open QC order?

Suggestions:
System will not allow to confirm Despatch, if QC order is opened for a same item code and lot no.
System will allow to confirm the Despatch if the QC order of the particular item and its lot number is passed or closed.