Commit cbdf6f70 authored by Aaron Bray's avatar Aaron Bray
Browse files

Add more actions/conditions to C#

parent e2a4315f
......@@ -34,4 +34,4 @@ public:
protected:
SENutrition* m_Nutrition;
std::string m_NutritionFile;
};
};
......@@ -35,5 +35,5 @@ protected:
SEScalarArea* m_ImpairedSurfaceArea;
SEScalar0To1* m_ImpairedFraction;
SEScalar0To1* m_Severity;
SEScalar0To1* m_Severity;
};
......@@ -21,5 +21,5 @@ public:
virtual void ToString(std::ostream &str) const;
protected:
};
};
......@@ -101,12 +101,21 @@
<Compile Include="cdm\io\PBEvents.cs" />
<Compile Include="cdm\io\PBLogMessages.cs" />
<Compile Include="cdm\io\PBMechanicalVentilator.cs" />
<Compile Include="cdm\io\PBNutrition.cs" />
<Compile Include="cdm\io\PBPatient.cs" />
<Compile Include="cdm\io\PBPatientActions.cs" />
<Compile Include="cdm\io\PBPatientConditions.cs" />
<Compile Include="cdm\io\PBPatientConfiguration.cs" />
<Compile Include="cdm\io\PBProperties.cs" />
<Compile Include="cdm\patient\actions\SEAcuteRespiratoryDistressSyndromeExacerbation.cs" />
<Compile Include="cdm\patient\actions\SEConsciousRespiration.cs" />
<Compile Include="cdm\patient\actions\SEUrinate.cs" />
<Compile Include="cdm\patient\actions\SEPulmonaryShuntExacerbation.cs" />
<Compile Include="cdm\patient\actions\SEMechanicalVentilation.cs" />
<Compile Include="cdm\patient\actions\SEImpairedAlveolarExchangeExacerbation.cs" />
<Compile Include="cdm\patient\actions\SEConsumeNutrients.cs" />
<Compile Include="cdm\patient\actions\SEChestCompressionForceScale.cs" />
<Compile Include="cdm\patient\actions\SEChestCompressionForce.cs" />
<Compile Include="cdm\patient\actions\SEAcuteStress.cs" />
<Compile Include="cdm\patient\actions\SEAirwayObstruction.cs" />
<Compile Include="cdm\patient\actions\SEAsthmaAttack.cs" />
......@@ -127,8 +136,10 @@
<Compile Include="cdm\patient\actions\SESubstanceCompoundInfusion.cs" />
<Compile Include="cdm\patient\actions\SESubstanceInfusion.cs" />
<Compile Include="cdm\patient\actions\SESupplementalOxygen.cs" />
<Compile Include="cdm\patient\actions\SEChestOcclusiveDressing.cs" />
<Compile Include="cdm\patient\actions\SETensionPneumothorax.cs" />
<Compile Include="cdm\patient\conditions\SEAcuteRespiratoryDistressSyndrome.cs" />
<Compile Include="cdm\patient\conditions\SEPulmonaryShunt.cs" />
<Compile Include="cdm\patient\conditions\SEChronicAnemia.cs" />
<Compile Include="cdm\patient\conditions\SEChronicHeartFailure.cs" />
<Compile Include="cdm\patient\conditions\SEChronicObstructivePulmonaryDisease.cs" />
......@@ -140,6 +151,7 @@
<Compile Include="cdm\patient\conditions\SEPatientCondition.cs" />
<Compile Include="cdm\patient\conditions\SEPulmonaryFibrosis.cs" />
<Compile Include="cdm\patient\conditions\SESepsis.cs" />
<Compile Include="cdm\patient\SENutrition.cs" />
<Compile Include="cdm\patient\SEPatient.cs" />
<Compile Include="cdm\scalars\SEProperty.cs" />
<Compile Include="cdm\scalars\SEScalar.cs" />
......@@ -157,6 +169,7 @@
<Compile Include="cdm\scalars\SEScalarMassPerTime.cs" />
<Compile Include="cdm\scalars\SEScalarMassPerVolume.cs" />
<Compile Include="cdm\scalars\SEScalarNegative1To1.cs" />
<Compile Include="cdm\scalars\SEScalarForce.cs" />
<Compile Include="cdm\scalars\SEScalarPower.cs" />
<Compile Include="cdm\scalars\SEScalarPressureTimePerVolume.cs" />
<Compile Include="cdm\scalars\SEScalarPressure.cs" />
......
/* Distributed under the Apache License, Version 2.0.
See accompanying NOTICE file for details.*/
using System.Collections.Generic;
using Google.Protobuf;
namespace Pulse.CDM
{
public class PBNutrition
{
public static void Load(pulse.cdm.bind.NutritionData src, SENutrition dst)
{
Serialize(src, dst);
}
public static void Serialize(pulse.cdm.bind.NutritionData src, SENutrition dst)
{
dst.Clear();
if (src.Carbohydrate != null)
PBProperty.Load(src.Carbohydrate, dst.GetCarbohydrate());
if (src.CarbohydrateDigestionRate != null)
PBProperty.Load(src.CarbohydrateDigestionRate, dst.GetCarbohydrateDigestionRate());
if (src.Fat != null)
PBProperty.Load(src.Fat, dst.GetFat());
if (src.FatDigestionRate != null)
PBProperty.Load(src.FatDigestionRate, dst.GetFatDigestionRate());
if (src.Protein != null)
PBProperty.Load(src.Protein, dst.GetProtein());
if (src.ProteinDigestionRate != null)
PBProperty.Load(src.ProteinDigestionRate, dst.GetProteinDigestionRate());
if (src.Calcium != null)
PBProperty.Load(src.Calcium, dst.GetCalcium());
if (src.Sodium != null)
PBProperty.Load(src.Sodium, dst.GetSodium());
if (src.Water != null)
PBProperty.Load(src.Water, dst.GetWater());
}
public static bool SerializeFromString(string src, SENutrition dst)
{
try
{
pulse.cdm.bind.NutritionData data = JsonParser.Default.Parse<pulse.cdm.bind.NutritionData>(src);
PBNutrition.Load(data, dst);
}
catch (Google.Protobuf.InvalidJsonException)
{
return false;
}
return true;
}
public static pulse.cdm.bind.NutritionData Unload(SENutrition src)
{
pulse.cdm.bind.NutritionData dst = new pulse.cdm.bind.NutritionData();
Serialize(src, dst);
return dst;
}
public static void Serialize(SENutrition src, pulse.cdm.bind.NutritionData dst)
{
if (src.HasCarbohydrate())
dst.Carbohydrate = PBProperty.Unload(src.GetCarbohydrate());
if (src.HasCarbohydrateDigestionRate())
dst.CarbohydrateDigestionRate = PBProperty.Unload(src.GetCarbohydrateDigestionRate());
if (src.HasFat())
dst.Fat = PBProperty.Unload(src.GetFat());
if (src.HasFatDigestionRate())
dst.FatDigestionRate = PBProperty.Unload(src.GetFatDigestionRate());
if (src.HasProtein())
dst.Protein = PBProperty.Unload(src.GetProtein());
if (src.HasProteinDigestionRate())
dst.ProteinDigestionRate = PBProperty.Unload(src.GetProteinDigestionRate());
if (src.HasCalcium())
dst.Calcium = PBProperty.Unload(src.GetCalcium());
if (src.HasSodium())
dst.Sodium = PBProperty.Unload(src.GetSodium());
if (src.HasWater())
dst.Water = PBProperty.Unload(src.GetWater());
}
public static string SerializeToString(SENutrition src)
{
var pb = PBNutrition.Unload(src);
return pb.ToString();
}
}
}
This diff is collapsed.
......@@ -63,6 +63,12 @@ namespace Pulse.CDM
Serialize(any.PulmonaryFibrosis, pf);
return pf;
}
if (any.PulmonaryShunt != null)
{
SEPulmonaryShunt ps = new SEPulmonaryShunt();
Serialize(any.PulmonaryShunt, ps);
return ps;
}
if (any.Sepsis != null)
{
SESepsis s = new SESepsis();
......@@ -121,6 +127,11 @@ namespace Pulse.CDM
any.PulmonaryFibrosis = Unload((SEPulmonaryFibrosis)Condition);
return any;
}
if (Condition.GetType().IsAssignableFrom(typeof(SEPulmonaryShunt)))
{
any.PulmonaryShunt = Unload((SEPulmonaryShunt)Condition);
return any;
}
if (Condition.GetType().IsAssignableFrom(typeof(SESepsis)))
{
any.Sepsis = Unload((SESepsis)Condition);
......@@ -401,6 +412,32 @@ namespace Pulse.CDM
}
#endregion
#region SEPulmonaryShunt
public static void Load(pulse.cdm.bind.PulmonaryShuntData src, SEPulmonaryShunt dst)
{
Serialize(src, dst);
}
public static void Serialize(pulse.cdm.bind.PulmonaryShuntData src, SEPulmonaryShunt dst)
{
Serialize(src.PatientCondition, dst);
if (src.Severity != null)
PBProperty.Load(src.Severity, dst.GetSeverity());
}
public static pulse.cdm.bind.PulmonaryShuntData Unload(SEPulmonaryShunt src)
{
pulse.cdm.bind.PulmonaryShuntData dst = new pulse.cdm.bind.PulmonaryShuntData();
Serialize(src, dst);
return dst;
}
public static void Serialize(SEPulmonaryShunt src, pulse.cdm.bind.PulmonaryShuntData dst)
{
dst.PatientCondition = new pulse.cdm.bind.PatientConditionData();
Serialize(src, dst.PatientCondition);
if (src.HasSeverity())
dst.Severity = PBProperty.Unload(src.GetSeverity());
}
#endregion
#region SESepsis
public static void Load(pulse.cdm.bind.SepsisData src, SESepsis dst)
{
......
......@@ -80,6 +80,31 @@ namespace Pulse.CDM
}
#endregion
#region SEScalarForce
public static void Load(pulse.cdm.bind.ScalarForceData src, SEScalarForce dst)
{
Serialize(src, dst);
}
public static void Serialize(pulse.cdm.bind.ScalarForceData src, SEScalarForce dst)
{
dst.Invalidate();
dst.SetValue(src.ScalarForce.Value, ForceUnit.FromString(src.ScalarForce.Unit));
}
public static pulse.cdm.bind.ScalarForceData Unload(SEScalarForce src)
{
pulse.cdm.bind.ScalarForceData dst = new pulse.cdm.bind.ScalarForceData();
Serialize(src, dst);
return dst;
}
public static void Serialize(SEScalarForce src, pulse.cdm.bind.ScalarForceData dst)
{
dst.ScalarForce = new pulse.cdm.bind.ScalarData();
dst.ScalarForce.Value = src.GetValue();
dst.ScalarForce.Unit = src.GetUnit().ToString();
}
#endregion
#region SEScalarFrequency
public static void Load(pulse.cdm.bind.ScalarFrequencyData src, SEScalarFrequency dst)
{
......
/* Distributed under the Apache License, Version 2.0.
See accompanying NOTICE file for details.*/
namespace Pulse.CDM
{
public class SENutrition
{
protected SEScalarMass carbohydrate;
protected SEScalarMassPerTime carbohydrate_digestion_rate;
protected SEScalarMass fat;
protected SEScalarMassPerTime fat_digestion_rate;
protected SEScalarMass protein;
protected SEScalarMassPerTime protein_digestion_rate;
protected SEScalarMass calcium;
protected SEScalarMass sodium;
protected SEScalarVolume water;
public SENutrition()
{
carbohydrate = null;
carbohydrate_digestion_rate = null;
fat = null;
fat_digestion_rate = null;
protein = null;
protein_digestion_rate = null;
calcium = null;
sodium = null;
water = null;
}
public void Clear()
{
if (carbohydrate != null) { carbohydrate.Invalidate(); }
if (carbohydrate_digestion_rate != null) { carbohydrate_digestion_rate.Invalidate(); }
if (fat != null) { fat.Invalidate(); }
if (fat_digestion_rate != null) { fat_digestion_rate.Invalidate(); }
if (protein != null) { protein.Invalidate(); }
if (protein_digestion_rate != null) { protein_digestion_rate.Invalidate(); }
if (calcium != null) { calcium.Invalidate(); }
if (sodium != null) { sodium.Invalidate(); }
if (water != null) { water.Invalidate(); }
}
public void Copy(SENutrition src)
{
Clear();
if (src.HasCarbohydrate()) { GetCarbohydrate().Set(src.carbohydrate); }
if (src.HasCarbohydrateDigestionRate()) { GetCarbohydrateDigestionRate().Set(src.carbohydrate_digestion_rate); }
if (src.HasFat()) { GetFat().Set(src.fat); }
if (src.HasFatDigestionRate()) { GetFatDigestionRate().Set(src.fat_digestion_rate); }
if (src.HasProtein()) { GetProtein().Set(src.protein); }
if (src.HasProteinDigestionRate()) { GetProteinDigestionRate().Set(src.protein_digestion_rate); }
if (src.HasCalcium()) { GetCalcium().Set(src.calcium); }
if (src.HasSodium()) { GetSodium().Set(src.sodium); }
if (src.HasWater()) { GetWater().Set(src.water); }
}
public bool SerializeFromFile(string filename)
{
try
{
string json = System.IO.File.ReadAllText(filename);
return SerializeFromString(json, SerializationFormat.JSON);
}
catch (System.Exception ex)
{
System.Console.WriteLine("Error Reading Nutrition File! " + ex.ToString());
return false;
}
}
public bool SerializeFromString(string src, SerializationFormat fmt)
{
return PBNutrition.SerializeFromString(src, this);
}
public bool SerializeToFile(string filename)
{
string json = SerializeToString(SerializationFormat.JSON);
if (json == null || json.Length == 0)
return false;
try
{
System.IO.File.WriteAllText(filename, json);
}
catch (System.Exception ex)
{
System.Console.WriteLine("Error Writing Patient File! " + ex.ToString());
return false;
}
return true;
}
public string SerializeToString(SerializationFormat format)
{
return PBNutrition.SerializeToString(this);
}
public bool HasCarbohydrate()
{
return carbohydrate == null ? false : carbohydrate.IsValid();
}
public SEScalarMass GetCarbohydrate()
{
if (carbohydrate == null)
carbohydrate = new SEScalarMass();
return carbohydrate;
}
public bool HasCarbohydrateDigestionRate()
{
return carbohydrate_digestion_rate == null ? false : carbohydrate_digestion_rate.IsValid();
}
public SEScalarMassPerTime GetCarbohydrateDigestionRate()
{
if (carbohydrate_digestion_rate == null)
carbohydrate_digestion_rate = new SEScalarMassPerTime();
return carbohydrate_digestion_rate;
}
public bool HasFat()
{
return fat == null ? false : fat.IsValid();
}
public SEScalarMass GetFat()
{
if (fat == null)
fat = new SEScalarMass();
return fat;
}
public bool HasFatDigestionRate()
{
return fat_digestion_rate == null ? false : fat_digestion_rate.IsValid();
}
public SEScalarMassPerTime GetFatDigestionRate()
{
if (fat_digestion_rate == null)
fat_digestion_rate = new SEScalarMassPerTime();
return fat_digestion_rate;
}
public bool HasProtein()
{
return protein == null ? false : protein.IsValid();
}
public SEScalarMass GetProtein()
{
if (protein == null)
protein = new SEScalarMass();
return protein;
}
public bool HasProteinDigestionRate()
{
return protein_digestion_rate == null ? false : protein_digestion_rate.IsValid();
}
public SEScalarMassPerTime GetProteinDigestionRate()
{
if (protein_digestion_rate == null)
protein_digestion_rate = new SEScalarMassPerTime();
return protein_digestion_rate;
}
public bool HasCalcium()
{
return calcium == null ? false : calcium.IsValid();
}
public SEScalarMass GetCalcium()
{
if (calcium == null)
calcium = new SEScalarMass();
return calcium;
}
public bool HasSodium()
{
return sodium == null ? false : sodium.IsValid();
}
public SEScalarMass GetSodium()
{
if (sodium == null)
sodium = new SEScalarMass();
return sodium;
}
public bool HasWater()
{
return water == null ? false : water.IsValid();
}
public SEScalarVolume GetWater()
{
if (water == null)
water = new SEScalarVolume();
return water;
}
}
}
/* Distributed under the Apache License, Version 2.0.
See accompanying NOTICE file for details.*/
namespace Pulse.CDM
{
public class SEChestCompressionForce : SEPatientAction
{
protected SEScalarForce force;
public SEChestCompressionForce()
{
force = null;
}
public override void Clear()
{
base.Clear();
if (force != null)
force.Invalidate();
}
public override bool IsValid()
{
return HasForce();
}
public bool HasForce()
{
return force == null ? false : force.IsValid();
}
public SEScalarForce GetForce()
{
if (force == null)
force = new SEScalarForce();
return force;
}
}
}
/* Distributed under the Apache License, Version 2.0.
See accompanying NOTICE file for details.*/
namespace Pulse.CDM
{
public class SEChestCompressionForceScale : SEPatientAction
{
protected SEScalar0To1 force_scale;
protected SEScalarTime force_period;
public SEChestCompressionForceScale()
{
force_scale = null;
force_period = null;
}
public override void Clear()
{
base.Clear();
if (force_scale != null)
force_scale.Invalidate();
if (force_period != null)
force_period.Invalidate();
}
public override bool IsValid()
{
return HasForceScale() && HasForcePeriod();
}
public bool HasForceScale()
{
return force_scale == null ? false : force_scale.IsValid();
}
public SEScalar0To1 GetForceScale()
{
if (force_scale == null)
force_scale = new SEScalar0To1();
return force_scale;
}
public bool HasForcePeriod()
{
return force_period == null ? false : force_period.IsValid();
}
public SEScalarTime GetForcePeriod()
{
if (force_period == null)
force_period = new SEScalarTime();
return force_period;
}
}
}
/* Distributed under the Apache License, Version 2.0.
See accompanying NOTICE file for details.*/
namespace Pulse.CDM
{
public class SEChestOcclusiveDressing : SEPatientAction
{
protected eSwitch state;
protected eSide side;
public SEChestOcclusiveDressing()
{
state = eSwitch.NullSwitch;
side = eSide.NullSide;
}
public override void Clear()
{
base.Clear();
state = eSwitch.NullSwitch;
side = eSide.NullSide;
}
public override bool IsValid()
{
return HasState() && HasSide();
}
public eSwitch GetState()
{
return state;
}
public void SetState(eSwitch type)
{
this.state = type;
}
public bool HasState()
{
return state == eSwitch.NullSwitch ? false : true;
}
public eSide GetSide()
{
return side;
}
public void SetSide(eSide side)
{
this.side = side;
}
public bool HasSide()
{