syntax = "proto3";
package pulse.cdm.bind;
option java_package = "com.kitware.pulse.cdm.bind";
option csharp_namespace = "pulse.cdm.bind";
option optimize_for = SPEED;

import "pulse/cdm/bind/Actions.proto";
import "pulse/cdm/bind/Enums.proto";
import "pulse/cdm/bind/MechanicalVentilator.proto";
import "pulse/cdm/bind/Properties.proto";

message MechanicalVentilatorActionData
{
  EquipmentActionData                          EquipmentAction                           = 1;
}

/** @brief The configuration of the mechanical ventilator to use. */
message MechanicalVentilatorConfigurationData
{
 MechanicalVentilatorActionData                MechanicalVentilatorAction                = 1;
  oneof Option
  {
    MechanicalVentilatorSettingsData           Settings                                  = 2; /**<< @brief A settings object with properties to set in the system object. */
    string                                     SettingsFile                              = 3; /**<< @brief File containing a settings object with properties to set in the system object. */
  }
  eMergeType                                   MergeType                                 = 4; /**<< @brief How to apply provided configuration to internal data model. */
}

message MechanicalVentilatorHoldData
{
  MechanicalVentilatorActionData               MechanicalVentilatorAction                = 1;
  eSwitch                                      State                                     = 2; /**<< @brief On = Activate the hold. Off = Release the hold. */
  eAppliedRespiratoryCycle                     AppliedRespiratoryCycle                   = 3; /**<< @brief When, in the respiratory cycle, to apply the hold. Not used if Switch is Off. */
}


message MechanicalVentilatorLeakData
{
  MechanicalVentilatorActionData               MechanicalVentilatorAction                = 1;
  Scalar0To1Data                               Severity                                  = 2; /**<< @brief Severity of the Leak, 0 = Off. */
}

message MechanicalVentilatorModeData
{
  MechanicalVentilatorActionData               MechanicalVentilatorAction                = 1;
  
  eSwitch                                      Connection                                = 2; /**<< @brief @ref eSwitchTable */
}

message MechanicalVentilatorContinuousPositiveAirwayPressureData
{
  MechanicalVentilatorModeData                 MechanicalVentilatorMode                  = 1;
  
  ScalarPressureData                           DeltaPressureSupport                      = 2; /**<< @brief Defines the driver pressure as the difference between PIP and PEEP */

  /** If no expiration cycle is provided we will start expiration based on the respiratory model. */
  ScalarVolumePerTimeData                      ExpirationCycleFlow                       = 3; /**<< @brief OPTIONAL Ventilator sensor flow value to trigger expiration phase. */
  ScalarPressureData                           ExpirationCyclePressure                   = 4; /**<< @brief OPTIONAL Ventilator sensor pressure value to trigger expiration phase. */

  eDriverWaveform                              ExpirationWaveform                        = 5; /**<< @brief OPTIONAL @ref MechanicalVentilatorData_eDriverWaveformTable */
  Scalar0To1Data                               FractionInspiredOxygen                    = 6; /**<< @brief FiO2 */

  /** If no patient trigger is provided we will trigger based on the respiratory model. */
  ScalarVolumePerTimeData                      InspirationPatientTriggerFlow             = 7; /**<< @brief OPTIONAL Ventilator sensor flow value to trigger inspiration phase. */
  ScalarPressureData                           InspirationPatientTriggerPressure         = 8; /**<< @brief OPTIONAL Ventilator sensor pressure value to trigger inspiration phase. */

  eDriverWaveform                              InspirationWaveform                       = 9;/**<< @brief OPTIONAL @ref MechanicalVentilatorData_eDriverWaveformTable */
  ScalarPressureData                           PositiveEndExpiredPressure                = 10;/**<< @brief Driver pressure during exhale */
  ScalarTimeData                               Slope                                     = 11;/**<< @brief OPTIONAL Time to reach PIP */
}

message MechanicalVentilatorPressureControlData
{
  enum eMode
  {
    AssistedControl                = 0;
    ContinuousMandatoryVentilation = 1;
  }

  MechanicalVentilatorModeData                 MechanicalVentilatorMode                  = 1;

  eMode                                        Mode                                      = 2;
  Scalar0To1Data                               FractionInspiredOxygen                    = 3; /**<< @brief FiO2 */

  /** If no patient trigger is provided we will trigger based on the respiratory model. */
  ScalarVolumePerTimeData                      InspirationPatientTriggerFlow             = 4; /**<< @brief OPTIONAL Ventilator sensor flow value to trigger inspiration phase. */
  ScalarPressureData                           InspirationPatientTriggerPressure         = 5; /**<< @brief OPTIONAL Ventilator sensor pressure value to trigger inspiration phase. */

  eDriverWaveform                              InspirationWaveform                       = 6; /**<< @brief OPTIONAL @ref MechanicalVentilatorData_eDriverWaveformTable */
  ScalarTimeData                               InspiratoryPeriod                         = 7; /**<< @brief OPTIONAL Time for inspiration part of the breathing cycle */
  ScalarPressureData                           InspiratoryPressure                       = 8; /**<< @brief Driver pressure during inspiration */
  ScalarPressureData                           PositiveEndExpiredPressure                = 9;/**<< @brief Driver pressure during exhale */
  ScalarFrequencyData                          RespirationRate                           = 10;/**<< @brief Driver minimum frequency */
  ScalarTimeData                               Slope                                     = 11;/**<< @brief OPTIONAL Time to reach PIP */
}

message MechanicalVentilatorVolumeControlData
{
  enum eMode
  {
    AssistedControl                = 0;
    ContinuousMandatoryVentilation = 1;
  }

  MechanicalVentilatorModeData                 MechanicalVentilatorMode                  = 1;

  eMode                                        Mode                                      = 2;
  ScalarVolumePerTimeData                      Flow                                      = 3; /**<< @brief Driver flow during inspiration */
  Scalar0To1Data                               FractionInspiredOxygen                    = 4; /**<< @brief FiO2 */

  /** If no patient trigger is provided we will trigger based on the respiratory model. */
  ScalarVolumePerTimeData                      InspirationPatientTriggerFlow             = 5; /**<< @brief OPTIONAL Ventilator sensor flow value to trigger inspiration phase. */
  ScalarPressureData                           InspirationPatientTriggerPressure         = 6; /**<< @brief OPTIONAL Ventilator sensor pressure value to trigger inspiration phase. */

  eDriverWaveform                              InspirationWaveform                       = 7; /**<< @brief OPTIONAL @ref MechanicalVentilatorData_eDriverWaveformTable */
  ScalarTimeData                               InspiratoryPeriod                         = 8; /**<< @brief OPTIONAL Time for inspiration part of the breathing cycle */
  ScalarPressureData                           PositiveEndExpiredPressure                = 9;/**<< @brief Driver pressure during exhale */
  ScalarFrequencyData                          RespirationRate                           = 10;/**<< @brief Driver minimum frequency */
  ScalarTimeData                               Slope                                     = 11;/**<< @brief OPTIONAL Time to reach tidal volume */
  ScalarVolumeData                             TidalVolume                               = 12;/**<< @brief Volume target/limit */
}

