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/Plots.proto";
import "pulse/cdm/bind/Patient.proto";
import "pulse/cdm/bind/Properties.proto";


// This encapsulates a row from our System/Patient validation spreedsheet
// It also encapsulates a segment property cell from a scenario validation spreedsheet

message ValidationTargetData
{
  string                                                Header                          = 1;
  string                                                Reference                       = 2;
  string                                                Notes                           = 3;
  string                                                TableFormatting                 = 4;/**<< @brief Specification string for floating point formatting of computed values in tables */
  
  optional string                                       ComputedEnum                    = 5;
  optional double                                       ComputedValue                   = 6;
  optional double                                       Error                           = 7;
  optional double                                       GoodPercentError                = 8;/**<< @brief We meet Good validation if Error is <= this percent, typically 10% */
  optional double                                       FairPercentError                = 9;/**<< @brief We meet Fair validation if Error is <= this percent, typically 30%, anything over is considered Poor validation */

}

message SegmentValidationTargetData
{
  ValidationTargetData                                  ValidationTarget                = 1;
  string                                                ComparisonFormula               = 2;/**<< @brief a formula to solve, that can include values from other segment, to compute the target value */

}
message SegmentValidationSegmentData
{
  int32                                                 Segment                         = 1;
  string                                                Notes                           = 2;
  repeated SegmentValidationTargetData                  SegmentValidationTarget         = 3;
}
message SegmentValidationSegmentListData
{
  repeated SegmentValidationSegmentData                 SegmentValidationSegment        = 1;
}
message SegmentValidationSegmentTableData
{
  string                                                TableName                       = 1;
  string                                                ScenarioName                    = 2;
  int32                                                 Segment                         = 3;
  repeated string                                       DataRequestFile                 = 4;
  repeated string                                       Header                          = 5;  /** May need to consider a mapping from headers to references **/
}
message SegmentValidationSegmentTableListData
{
  repeated SegmentValidationSegmentTableData            Table                           = 1;
}
message SegmentValidationPipelineConfigurationData
{
  PlotterListData                                       Plots                           = 1;
  SegmentValidationSegmentTableListData                 Tables                          = 2;
}

message TimeSeriesValidationTargetData
{
  enum eType
  {
    Mean     = 0;
    Minimum  = 1;
    Maximum  = 2;
    MeanPerIdealWeight_kg = 3;
    MinPerIdealWeight_kg = 4;
    MaxPerIdealWeight_kg = 5;
    Enumeration = 6;
  }
  ValidationTargetData                                  ValidationTarget                = 1;
  string                                                Assessment                      = 2;
  bool                                                  PatientSpecific                 = 3;/**<< @brief Should the target value change due to patient properties, if false, the expected value is only valid for standard patients. */
  eType                                                 Type                            = 4;
  
  oneof Expected
  {
    string                                              TargetEnum                      = 5;
    double                                              TargetValue                     = 6;
    RangeData                                           TargetRange                     = 7;
  }

}
message TimeSeriesValidationTargetListData
{
  repeated TimeSeriesValidationTargetData               TimeSeriesValidationTarget      = 1;
}

message PatientTimeSeriesValidationData
{
  PatientData                                           Patient                         = 1;
  map<string,TimeSeriesValidationTargetListData>        TimeSeriesValidationTargetMap   = 2;/**< @brief key is intended to be a table name, and the list is the table content. */
}
message PatientTimeSeriesValidationListData
{
  repeated PatientTimeSeriesValidationData              PatientTimeSeriesValidation     = 1;
}
