If you have transmitted a medication in error, then the delete (red X) button will not be enabled. You must use the STOP button in this case in order to preserve history that the medication was indeed sent to the pharmacy. This will allow you to "stop" the prescription with a reason. Then, you have the option to send this cancel message to the pharmacy:
You then probably do not want the medication to show on the Encounter Summary. This is controlled by the ListItems under Admin for each Reason. For example, below you can see there are two Medication Change Status Reasons set to "not show...".
Navigate to Admin -> Lists -> List Item Entry and select the List named “Med Status Change Reason” you will be able to set any of the reasons listed to “Do Not Show in Stopped Meds” You can also add reasons to to this list on this screen. If the Med Status Change Reason Behavior value shows blank, then the default behavior will be followed which is to Show in Stopped Meds.