An apparatus for detecting the deteriorating health of a patient receiving gas from a respiratory device, the apparatus comprising: a sensor unit configured to monitor a flow rate or pressure of a gas that is flowing in a pipe that connects the respiratory device to a gas delivery device worn by the patient; and a processor configured to measure a respiratory rate of the patient based on variations in the flow rate or pressure of gas in the pipe and to implement a trend analysis of the measured respiratory rate; wherein the processor is configured to generate a warning when it determines that there is an upward trend in the measured respiratory rate and that a magnitude of the trend exceeds a threshold; wherein the sensor unit comprises a sensor device configured to monitor the variations in the flow rate or pressure that are induced by the respiration of the patient, and to output a signal that is proportional to a derivative of the flow rate or pressure with respect to time; characterized in that: the processor is configured to detect peaks in the monitored flow rate or pressure by implementing discrete-time integration of the output of the sensor device to determine the flow rate or pressure of a flow that is induced by the respiration of the patient, and to then process the determined flow rate or pressure to detect local maxima, and to determine a measure of the respiratory rate of the patient using the separation between the detected maxima. a sensor unit configured to monitor a flow rate or pressure of a gas that is flowing in a pipe that connects the respiratory device to a gas delivery device worn by the patient; and a processor configured to measure a respiratory rate of the patient based on variations in the flow rate or pressure of gas in the pipe and to implement a trend analysis of the measured respiratory rate; wherein the processor is configured to generate a warning when it determines that there is an upward trend in the measured respiratory rate and that a magnitude of the trend exceeds a threshold; wherein the sensor unit comprises a sensor device configured to monitor the variations in the flow rate or pressure that are induced by the respiration of the patient, and to output a signal that is proportional to a derivative of the flow rate or pressure with respect to time; characterized in that: the processor is configured to detect peaks in the monitored flow rate or pressure by implementing discrete-time integration of the output of the sensor device to determine the flow rate or pressure of a flow that is induced by the respiration of the patient, and to then process the determined flow rate or pressure to detect local maxima, and to determine a measure of the respiratory rate of the patient using the separation between the detected maxima. the processor is configured to detect peaks in the monitored flow rate or pressure by implementing discrete-time integration of the output of the sensor device to determine the flow rate or pressure of a flow that is induced by the respiration of the patient, and to then process the determined flow rate or pressure to detect local maxima, and to determine a measure of the respiratory rate of the patient using the separation between the detected maxima.