HiRef: Leveraging Hierarchical Ontology and Network Refinement for Robust Medication Recommendation