Update MedicationFrequency.groovy

Bug fixes:
1. check for reference values equal to null
2. ONLY check for fields if medication exists