You are given a string containing messy clinical notes. Your task is to extract medication names and their corresponding dosages. Medications can appear in various formats, and dosages may include numbers followed by units (e.g., mg, g, mL).
notes representing the clinical notes containing medication information.Example 1:
Input: notes = "Patient was prescribed 500mg of Amoxicillin and 250mg of Ibuprofen."
Output: [("Amoxicillin", "500mg"), ("Ibuprofen", "250mg")]
Example 2:
Input: notes = "Take 10mL of Cough Syrup twice daily."
Output: [("Cough Syrup", "10mL")]
notes = "Patient was prescribed 500mg of Amoxicillin and 250mg of Ibuprofen."Output[('Amoxicillin', '500mg'), ('Ibuprofen', '250mg')]WhyThe regex captures 'Amoxicillin' with '500mg' and 'Ibuprofen' with '250mg'.notes = "Take 10mL of Cough Syrup twice daily."Output[('Cough Syrup', '10mL')]WhyThe regex captures 'Cough Syrup' with '10mL'.Input string will not exceed 1000 charactersMedication names may contain letters and spacesDosages will be followed by a unit (mg, g, mL, etc.)def extract_medications(notes):