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.
I started work life designing research/clinical instrumentation. As SouthernYankee pointed out there are functions the ventilator will need to have such as pressure, volume, and flow control, O2 mix flow control, O2 saturation (Finger clip on thingy), respiratory rates (like a CPAP machine), ideally needs to breath with the patient, needs to work with mask and intubation tubes.
The Ideal of automating an AMBU bag has been around for a number of years. Some other items of interest to get your creative mojo flowing would also be to check out, infant ventilators as they are small and can be scaled up, modifying cpap machines as they already have most of the software and controls that can be hacked for your use. check out the Vortran Go2Vent and the Pneupac VR1. RasberryPi should easily handle these functions.