Study patients will be patients scheduled for ESD in our gastroenterology department, and blood pressure and pulse measured in the pre-procedure room will be considered baseline vital signs. At the start of the ESD procedure, MAC with remimazolam will be performed. A bolus of 5 mcg of remimazolam is given over 1 minute at the onset of sedation, followed by a continuous intravenous infusion of remimazolam at a rate of 0.1 to 0.4 mg/kg/hr during the procedure with a goal of a Modified Observer's Assessment of Alertness/Sedation Scale (MOAA/S) score of 2-3. Record the total amount of remimazolam infused during the procedure. For pain control during the procedure, administer 50 ug of fentanyl at baseline and an additional 25 ug bolus of fentanyl if the patient's blood pressure rises (\>20% of baseline systolic blood pressure) or pulse rate increases (\>20% of baseline heart rate) during the procedure, or if the patient moves. Enroll in the study if respiratory disturbance due to sedation overdose occurs during the procedure, resulting in 1) sustained hypoxia (SpO2 \< 94%) with a risk of severe hypoxia, or 2) irregular breathing and excessive diaphragmatic breathing that prevents the endoscopist from performing the procedure. If no respiratory disturbances occur during the procedure, patients will be withdrawn from the study and excluded from statistical analysis. If any of the above respiratory disturbances occur, the remimazolam dose will remain unchanged and flumazenil will be administered to see if there is improvement. Improvement will be considered to occur if the respiratory disturbance resolves within 30 seconds, resulting in an increase in oxygen saturation and sustained to the point where endoscopy can be resumed. Dosing follows a biased-coin up-and-down design. Start with an initial dose of 5 mcg and increase by 5 mcg in the next patient if there is no respiratory improvement. If there is respiratory improvement, the same dose is given in the next patient with a probability of 8/9 and a probability of 1/9, using the biased-coin method, a 5 mcg decrease is given in the next patient. To determine the probability, the principal investigator will randomly generate a number from 1 to 9 using a random number generator, and if the randomly generated number is 1 to 8, the dose will be maintained, and if the number is 9, the dose will be reduced. The minimum dose will be 5 mcg and the maximum dose will be 150 mcg. If there is no respiratory improvement with the medication, start by reducing the remimazolam rate by 30%, attempting to establish an airway by elevating the jaw joint, and if respiratory distress persists, inserting a nasopharyngeal airway device. If respiratory distress improves, resume the procedure. After the procedure is completed, ask the patient if they are awake.

The study will follow a biased-coin up-and-down design, with 60 patients who developed respiratory disturbances during MAC with remimazolam for ESD as the final analysis population. The incidence of respiratory disturbances among patients undergoing MAC with remimazolam for ESD at our institution is about 40%, so 167 patients are needed, and we will apply the usual study dropout rate of 10% to target 167 patients undergoing MAC with remimazolam for ESD. However, if 60 patients develop respiratory distress before enrolling 167, and the study procedure is completed, the study will be terminated. The data from all 60 cases will then be used to find the ED90 using centered isotonic regression. Centered isotonic regression is a method of finding the proportion of patients who responded at each dose level and using this to obtain a cumulative distribution function of the proportion of patients who responded to the dose.17 This provides an estimate and confidence interval for the primary endpoint, the ED90 for improvement in respiratory impairment, and the probability of awakening, the secondary endpoint, at that ED90 dose, to assess the likelihood of during-procedure awakening at that ED90 dose.