A long time ago I worked on a software hardware project to build the first microprocessor based ventilator. Have not work on it in over 40 years. But the main problem with the ventilator is the hardware to detect the temperature, humidity and the pressure fluctuation. People are still breathing as you are putting air / O2 in. You have to follow their irregular breathing pattern. It is not easy to do. The hardware part of the control loop is very very difficult. The project i was on spent over $750,000 on just the sensor hardware development, and it was not 100% perfect, if you had a strong gag effect it would fail, then restart.