This documentation is for version 1 of Shen.ai SDK. To view the in-progress documentation for upcoming version 2, see docs-beta.shen.ai
Health risks
/
Integrating risks functionality

Integrating risks functionality

To provide Shen.AI information about user's risks factors you should use the following structure:

class RisksFactors {
  final int? age;
  final double? cholesterol;
  final double? cholesterolHdl;
  final double? sbp;
  final bool? isSmoker;
  final bool? hypertensionTreatment;
  final bool? hasDiabetes;
  final double? bodyHeight;
  final double? bodyWeight;
  final Gender? gender;
  final String? country;
  final Race? race;

  RisksFactors({
    this.age,
    this.cholesterol,
    this.cholesterolHdl,
    this.sbp,
    this.isSmoker,
    this.hypertensionTreatment,
    this.hasDiabetes,
    this.bodyHeight,
    this.bodyWeight,
    this.gender,
    this.country,
    this.race,
  });
}

enum Gender {
  MALE(0),
  FEMALE(1),
  OTHER(2);

  final int value;

  const Gender(this.value);
}

enum Race {
  WHITE(0),
  AFRICAN_AMERICAN(1),
  OTHER(2);

  final int value;

  const Race(this.value);
}

If some data is not provided, then risks which requires this data also won't be computed.

To compute the risks you should use computeHealthRisks() function. It returns the following structure, with filled only these fields, that could be computed with provided data:

static HealthRisks computeHealthRisks(RisksFactors healthRisksFactors);

class HealthRisks {
  final HardAndFatalEventsRisks? hardAndFatalEventsRisks;
  final CVDiseasesRisks? cvDiseases;
  final int? vascularAge;
  final RisksFactorsScores? scores;

  HealthRisks({
    this.hardAndFatalEventsRisks,
    this.cvDiseases,
    this.vascularAge,
    this.scores,
  });
}

The substructures are defined as follows:

class HardAndFatalEventsRisks {
  final double? coronaryDeathEventRisk;
  final double? fatalStrokeEventRisk;
  final double? totalCVMortalityRisk;
  final double? hardCVEventRisk;

  HardAndFatalEventsRisks({
    this.coronaryDeathEventRisk,
    this.fatalStrokeEventRisk,
    this.totalCVMortalityRisk,
    this.hardCVEventRisk,
  });
}

class CVDiseasesRisks {
  final double? overallRisk;
  final double? coronaryHeartDiseaseRisk;
  final double? strokeRisk;
  final double? heartFailureRisk;
  final double? peripheralVascularDiseaseRisk;

  CVDiseasesRisks({
    this.overallRisk,
    this.coronaryHeartDiseaseRisk,
    this.strokeRisk,
    this.heartFailureRisk,
    this.peripheralVascularDiseaseRisk,
  });
}

class RisksFactorsScores {
  final int? ageScore;
  final int? sbpScore;
  final int? smokingScore;
  final int? diabetesScore;
  final int? bmiScore;
  final int? cholesterolScore;
  final int? cholesterolHdlScore;
  final int? totalScore;

  RisksFactorsScores({
    this.ageScore,
    this.sbpScore,
    this.smokingScore,
    this.diabetesScore,
    this.bmiScore,
    this.cholesterolScore,
    this.cholesterolHdlScore,
    this.totalScore,
  });
}

Because different metrics have different value ranges, dependent also on the risks factors, Shen.AI provides methods to get minimal and maximal values for each risk.

static HealthRisks getMinimalHealthRisks(RisksFactors healthRisksFactors);
static HealthRisks getMaximalHealthRisks(RisksFactors healthRisksFactors);