@@ -972,6 +972,46 @@ def assert_drug_dose_unit_text(
972972 actual_text == expected_text
973973 ), f"Expected drug unit dose text '{ expected_text } ' but found '{ actual_text } '"
974974
975+ def assert_drug_dosage_unit_text (
976+ self , drug_type : str , drug_number : int , expected_text : str
977+ ) -> None :
978+ """
979+ Asserts that the drug dosage unit contains the expected text.
980+
981+ Args:
982+ drug_type (str): The drug type to check
983+ drug_number (int): The number of the drug dosage unit cell to check.
984+ expected_text (str): The expected text content of the cell.
985+
986+ Raises:
987+ AssertionError: If the actual text does not match the expected text.
988+ """
989+ locator = self .get_drug_dosage_text_locator (drug_type , drug_number )
990+ actual_text = locator .inner_text ().strip ()
991+
992+ logging .info (
993+ f"Drug dosage unit text for drug { drug_number } : "
994+ f"'{ actual_text } ' (expected: '{ expected_text } ')"
995+ )
996+
997+ assert actual_text == expected_text , (
998+ f"Expected drug dosage unit text '{ expected_text } ' "
999+ f"but found '{ actual_text } '"
1000+ )
1001+
1002+ def get_drug_dosage_text_locator (self , drug_type : str , drug_number : int ) -> Locator :
1003+ """
1004+ Returns the drug dosage text locator for the matching drug type and number
1005+ Args:
1006+ drug_type (str): The drug type to check
1007+ drug_number (int): The number of the drug to check
1008+ """
1009+ if drug_type .lower () == "bowel preparation administered" :
1010+ locator_prefix = "#HILITE_spanBowelPrepDrugDosageUnit"
1011+ elif drug_type .lower () == "antibiotics administered" :
1012+ locator_prefix = "#HILITE_spanAntibioticDosageUnit"
1013+ return self .page .locator (f"{ locator_prefix } { drug_number } " )
1014+
9751015
9761016def normalize_label (text : str ) -> str :
9771017 """
0 commit comments