diff --git a/bin/EngineState.json b/bin/EngineState.json index 2eb993d79c6b245404d466ca61cd5dafe20307f0..1007b89418ea9c965f1cff1ff23627222c25d801 100644 --- a/bin/EngineState.json +++ b/bin/EngineState.json @@ -1,4 +1,4 @@ -{ +{"Scenario": { "Name":"BasicStandard", "Description":"Basic scenario measuring patient vitals with no insults or interventions", "EngineStateFile":"./states/StandardMale@0s.pbb", @@ -93,4 +93,21 @@ {"DecimalFormat":{"Precision":2}, "Category":"LiquidCompartment","CompartmentName":"Pericardium","PropertyName":"Pressure","Unit":"mmHg"} ]}, - "AnyAction":[{"AdvanceTime":{"Time":{"ScalarTime":{"Value":2.0,"Unit":"min"}}}}]} \ No newline at end of file + "AnyAction":[{"AdvanceTime":{"Time":{"ScalarTime":{"Value":2.0,"Unit":"min"}}}}]}, + + "Configuration": { + "AutoSerialization": { + "Directory": "./states/testing/", + "Filename": "patient/HemorrhageVaryingSeverity", + "AfterActions": "On", + "Period": { + "ScalarTime": { + "Value": 5.0, + "Unit": "s" + } + }, + "PeriodTimeStamps": "On", + "ReloadState": "On" + } + } +} diff --git a/data/config/DebugRun.config b/data/config/DebugRun.config index 0125847b47c17bd4033fc18d66966b0d6007c79f..a18fa71b133df5e6a2db0cf90938072baa5a654d 100644 --- a/data/config/DebugRun.config +++ b/data/config/DebugRun.config @@ -20,7 +20,7 @@ Threads=-1 #UseStates=true # AutoSerialize = Directory,Period(in seconds, 0 turns off constant saving),TimeStampPeriods,AfterActions,Reload # Time stamp periods is creating a file per save and using the time stamp as naming convention -#AutoSerialization=./states/testing/,5,On,On,On +#AutoSerialization=./states/testing/,0,On,On,On Executor=com.kitware.pulse.cdm.testing.CDMUnitTestDriver Executor=com.kitware.pulse.engine.testing.EngineUnitTestDriver diff --git a/data/human/adult/baselines/scenarios/patient/BasicStandard.zip.sha512 b/data/human/adult/baselines/scenarios/patient/BasicStandard.zip.sha512 index 8b96831069f7a1fd780d8b8340519510b69deefb..5e6288794b1a2071575fb19011192d78878699bc 100644 --- a/data/human/adult/baselines/scenarios/patient/BasicStandard.zip.sha512 +++ b/data/human/adult/baselines/scenarios/patient/BasicStandard.zip.sha512 @@ -1 +1 @@ -bd07f27c3f0d6cc856da6e620358fc188eacd92c022e45bcb5f4d3bbde6cd1e60562ecdb2be7b9c37f10d06e9fc1d4787b0993b177cad79a57804a2d4e15909e \ No newline at end of file +9307647712f9db911187dcb95226b5240a1f7a05ad1586a0515c70824d1e0612733c65bc23e13480f0d8616c6e41cd759c72a0f3f5757a30bc791bcac5e31e25 \ No newline at end of file diff --git a/data/human/adult/baselines/scenarios/patient/HemorrhageGroup1.zip.sha512 b/data/human/adult/baselines/scenarios/patient/HemorrhageGroup1.zip.sha512 index 48475442d9e09b5f75b17a7e0be62486b19010f7..0405dd6e21e7170852dce4c612eb35b350c8f9d1 100644 --- a/data/human/adult/baselines/scenarios/patient/HemorrhageGroup1.zip.sha512 +++ b/data/human/adult/baselines/scenarios/patient/HemorrhageGroup1.zip.sha512 @@ -1 +1 @@ -591afe15a133e9afcf524e7b3a2c3efbe0ec7b218a709cecf272aed10d87a09e566c8a7db0e1323f3e812ee445a782b7a9ce48856bd484e4ae9e4767ce0e55dc \ No newline at end of file +c3745fc76be849086017dd1ed8f3c7d271bfe9514d5d5b6dd8e7b723c3fc013d3f33c46ebbe5d04e0bfdb0d0adc4b036ddc756bab414c879ef2a1f37bb5abc54 \ No newline at end of file diff --git a/data/human/adult/baselines/scenarios/patient/HemorrhageGroup2.zip.sha512 b/data/human/adult/baselines/scenarios/patient/HemorrhageGroup2.zip.sha512 index 1edebea591c4f91bb3ab42359693aef368e1003c..dcabb2d6a96755beecf9887fe532a690ced88b54 100644 --- a/data/human/adult/baselines/scenarios/patient/HemorrhageGroup2.zip.sha512 +++ b/data/human/adult/baselines/scenarios/patient/HemorrhageGroup2.zip.sha512 @@ -1 +1 @@ -3e1ec5800fbd4c5d6133a65985d0c1f5a28393265ec787053988f855686de979e0165d5a83576436e328c87163d6cbf308a308524711a35b325eb1b7cd0ad595 \ No newline at end of file +2ce651ff7c127692cca4b3f7781a7f9156abadeebfe86b2950c73487408529b43f526b67992aceb9789936449204f1c1d4724039119afc5a7f19b8e31ddb71b6 \ No newline at end of file diff --git a/data/human/adult/baselines/scenarios/patient/HemorrhageGroup3.zip.sha512 b/data/human/adult/baselines/scenarios/patient/HemorrhageGroup3.zip.sha512 index 6626db07339f5e76407b4258aba27e0568025719..3badc8d993a05102f554cc9a6267ae94db326a4a 100644 --- a/data/human/adult/baselines/scenarios/patient/HemorrhageGroup3.zip.sha512 +++ b/data/human/adult/baselines/scenarios/patient/HemorrhageGroup3.zip.sha512 @@ -1 +1 @@ -1be2aded3eaa78f858fe1cb1e73749e5c707dc8bec2392374b3b3a703f70f0df626e9bb9e5fe1f4530e778c74668caed36907e9ded1a9173cf197f97cf0d2046 \ No newline at end of file +d43e04e62b6f5ed067905515dfb9dcb18d20e061a36744d99aeb8c011a95e6e22d9059d3fb50f989534bc853d8a5d0ed6cffb0891da008cd93c3d9928e2e17dc \ No newline at end of file diff --git a/data/human/adult/baselines/scenarios/patient/HemorrhageGroup4.zip.sha512 b/data/human/adult/baselines/scenarios/patient/HemorrhageGroup4.zip.sha512 index d5e4bee565913b32921916cdd5a950e5296ece7d..12415d913586a391ced1e94f19e0bfd3977eb2f4 100644 --- a/data/human/adult/baselines/scenarios/patient/HemorrhageGroup4.zip.sha512 +++ b/data/human/adult/baselines/scenarios/patient/HemorrhageGroup4.zip.sha512 @@ -1 +1 @@ -d4dfa870b7e0800c25d511617ca034c90e3357ea7429f75c74b1efcb2c941900a913d217cce9cc1c79b2e5f2779a7fbf150ea210e31a92b9f3e5ac9116467e9c \ No newline at end of file +2d64ce0d134a905d6012ab2b0205700b0f634a5d875fcc24743043f46350f34feee8ca7c9f409d3faa9bc1131f64d418478e0236fadab32fc717b92a6f98cec9 \ No newline at end of file diff --git a/data/human/adult/baselines/scenarios/patient/HemorrhageGroup5.zip.sha512 b/data/human/adult/baselines/scenarios/patient/HemorrhageGroup5.zip.sha512 index 482df6489fcd8eb61dcce79c0c3149d2fdd0a671..2f36f47bdb103063be642143a415b25005232fd5 100644 --- a/data/human/adult/baselines/scenarios/patient/HemorrhageGroup5.zip.sha512 +++ b/data/human/adult/baselines/scenarios/patient/HemorrhageGroup5.zip.sha512 @@ -1 +1 @@ -56a1630a5e1c3adf29c85e8b2442956695680122742188585a38d499982b9db75efec33f52b8d3a4458f749d6a0e0e38b8b263f5b82613986831aae4932cfbf7 \ No newline at end of file +bf026bec1da57cf9622b3205fe07c0d84c70aaa1cfb12a67b8018feed46512fd01d14d926a6f78f7e40aa4d7f1a7ab78c747845c351f84092fc305c4fbb183da \ No newline at end of file diff --git a/data/human/adult/baselines/scenarios/patient/HemorrhageGroup6.zip.sha512 b/data/human/adult/baselines/scenarios/patient/HemorrhageGroup6.zip.sha512 index 6971c12271627c6f66facd3a01abaaaa6c3d93aa..32b1ae32fa0bbe14043f43fe23913689e7f812a2 100644 --- a/data/human/adult/baselines/scenarios/patient/HemorrhageGroup6.zip.sha512 +++ b/data/human/adult/baselines/scenarios/patient/HemorrhageGroup6.zip.sha512 @@ -1 +1 @@ -af2de2b2c09d28623a78fff5808de9523bffd9d70bcc77346630a0a9eb652b0219dc36fcf20027a520727b55fa0aa141dda63a80ecc68ca01d01dd70f0e2829b \ No newline at end of file +fc9476f0534de111791edeb056ea334c115358c4f01ee4fffe01121d24e2bd6e6665863aa91edf81f9deba2d55c3e281e6314e23e6cd8f07992427fed17147e4 \ No newline at end of file diff --git a/data/human/adult/scenarios/patient/HemorrhageGroup1.json b/data/human/adult/scenarios/patient/HemorrhageGroup1.json index 90dfaa7c9f664f2a4419a3b38c2a8c59f4d0512a..5bda58f584506494330e85d66af8d652d9455832 100644 --- a/data/human/adult/scenarios/patient/HemorrhageGroup1.json +++ b/data/human/adult/scenarios/patient/HemorrhageGroup1.json @@ -20,13 +20,13 @@ { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TidalVolume", "Unit": "mL" }, { "DecimalFormat": { "Precision": 2 }, "Category": "Physiology", "PropertyName": "RespirationRate", "Unit": "1/min" }, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "OxygenSaturation", "Unit": "unitless" }, - - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "VenaCava", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "RightHeartVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "VenaCava", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "RightHeart", "PropertyName": "InFlow", "Unit": "mL/min" }, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "SystemicVascularResistance", "Unit": "mmHg s/mL"}, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TotalHemorrhageRate", "Unit": "mL/s"}, diff --git a/data/human/adult/scenarios/patient/HemorrhageGroup2.json b/data/human/adult/scenarios/patient/HemorrhageGroup2.json index 724b23c1a783a8d245708cb5d073f360b263cf7b..2c95dc4e83067de5ae3850323d3be5c50ca7c244 100644 --- a/data/human/adult/scenarios/patient/HemorrhageGroup2.json +++ b/data/human/adult/scenarios/patient/HemorrhageGroup2.json @@ -20,13 +20,13 @@ { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TidalVolume", "Unit": "mL" }, { "DecimalFormat": { "Precision": 2 }, "Category": "Physiology", "PropertyName": "RespirationRate", "Unit": "1/min" }, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "OxygenSaturation", "Unit": "unitless" }, - - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "VenaCava", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "RightHeartVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "VenaCava", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "RightHeart", "PropertyName": "InFlow", "Unit": "mL/min" }, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "SystemicVascularResistance", "Unit": "mmHg s/mL"}, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TotalHemorrhageRate", "Unit": "mL/s"}, diff --git a/data/human/adult/scenarios/patient/HemorrhageGroup3.json b/data/human/adult/scenarios/patient/HemorrhageGroup3.json index 4df412ec5a88a059b8e5c9cea9a11efa99a6437c..c43089d9f25f0a85cdab22f15942b9b73e6474b5 100644 --- a/data/human/adult/scenarios/patient/HemorrhageGroup3.json +++ b/data/human/adult/scenarios/patient/HemorrhageGroup3.json @@ -20,13 +20,13 @@ { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TidalVolume", "Unit": "mL" }, { "DecimalFormat": { "Precision": 2 }, "Category": "Physiology", "PropertyName": "RespirationRate", "Unit": "1/min" }, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "OxygenSaturation", "Unit": "unitless" }, - - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "VenaCava", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "RightHeartVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "VenaCava", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "RightHeart", "PropertyName": "InFlow", "Unit": "mL/min" }, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "SystemicVascularResistance", "Unit": "mmHg s/mL"}, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TotalHemorrhageRate", "Unit": "mL/s"}, diff --git a/data/human/adult/scenarios/patient/HemorrhageGroup4.json b/data/human/adult/scenarios/patient/HemorrhageGroup4.json index b939c49a7e82d769202d4510d4900179e05d0bdf..280fb59d8e251ed713aa49159b3adc0964b21dde 100644 --- a/data/human/adult/scenarios/patient/HemorrhageGroup4.json +++ b/data/human/adult/scenarios/patient/HemorrhageGroup4.json @@ -20,13 +20,13 @@ { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TidalVolume", "Unit": "mL" }, { "DecimalFormat": { "Precision": 2 }, "Category": "Physiology", "PropertyName": "RespirationRate", "Unit": "1/min" }, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "OxygenSaturation", "Unit": "unitless" }, - - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "VenaCava", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "RightHeartVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "VenaCava", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "RightHeart", "PropertyName": "InFlow", "Unit": "mL/min" }, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "SystemicVascularResistance", "Unit": "mmHg s/mL"}, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TotalHemorrhageRate", "Unit": "mL/s"}, diff --git a/data/human/adult/scenarios/patient/HemorrhageGroup5.json b/data/human/adult/scenarios/patient/HemorrhageGroup5.json index 5bd846306493eeb506749dd6a2366393107a3034..1aa051c0ac1811557e178f98d487d3ff7802b9cb 100644 --- a/data/human/adult/scenarios/patient/HemorrhageGroup5.json +++ b/data/human/adult/scenarios/patient/HemorrhageGroup5.json @@ -20,13 +20,13 @@ { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TidalVolume", "Unit": "mL" }, { "DecimalFormat": { "Precision": 2 }, "Category": "Physiology", "PropertyName": "RespirationRate", "Unit": "1/min" }, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "OxygenSaturation", "Unit": "unitless" }, - - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "VenaCava", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "RightHeartVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "VenaCava", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "RightHeart", "PropertyName": "InFlow", "Unit": "mL/min" }, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "SystemicVascularResistance", "Unit": "mmHg s/mL"}, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TotalHemorrhageRate", "Unit": "mL/s"}, diff --git a/data/human/adult/scenarios/patient/HemorrhageGroup6.json b/data/human/adult/scenarios/patient/HemorrhageGroup6.json index 1a48f1d6a79814210e69c092a57c45e4dd496d32..21ee19349bca748ecb9b50c441f27d9eaece9b10 100644 --- a/data/human/adult/scenarios/patient/HemorrhageGroup6.json +++ b/data/human/adult/scenarios/patient/HemorrhageGroup6.json @@ -21,12 +21,12 @@ { "DecimalFormat": { "Precision": 2 }, "Category": "Physiology", "PropertyName": "RespirationRate", "Unit": "1/min" }, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "OxygenSaturation", "Unit": "unitless" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "VenaCava", "PropertyName": "InFlow", "Unit": "mL/min" }, - { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "RightHeartVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "SubstanceName": "Oxygen", "PropertyName": "PartialPressure", "Unit": "mmHg" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "MyocardiumVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "BrainVasculature", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "VenaCava", "PropertyName": "InFlow", "Unit": "mL/min" }, + { "DecimalFormat": { "Precision": 4 }, "Category": "LiquidCompartment", "CompartmentName": "RightHeart", "PropertyName": "InFlow", "Unit": "mL/min" }, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "SystemicVascularResistance", "Unit": "mmHg s/mL"}, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TotalHemorrhageRate", "Unit": "mL/s"}, diff --git a/data/human/adult/scenarios/patient/HemorrhageSeverity1.json b/data/human/adult/scenarios/patient/HemorrhageSeverity1.json index 55b468675ecae58bf8863db45dc252187edb81d7..f950a2fcf847b1c9ef9e5863fea26ad6fcd5e16a 100644 --- a/data/human/adult/scenarios/patient/HemorrhageSeverity1.json +++ b/data/human/adult/scenarios/patient/HemorrhageSeverity1.json @@ -64,7 +64,9 @@ { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "SystemicVascularResistance", "Unit": "mmHg s/mL"}, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TotalHemorrhageRate", "Unit": "mL/s"}, - { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TotalHemorrhagedVolume", "Unit": "mL"} + { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TotalHemorrhagedVolume", "Unit": "mL"}, + { "DecimalFormat": { "Precision": 3 }, "Category": "Action", "ActionName": "Hemorrhage", "CompartmentName": "RightLegVasculature", "PropertyName": "FlowRate", "Unit": "mL/s"}, + { "DecimalFormat": { "Precision": 3 }, "Category": "Action", "ActionName": "Hemorrhage", "CompartmentName": "RightLegVasculature", "PropertyName": "TotalBloodLost", "Unit": "mL"} ] }, "AnyAction": [{ diff --git a/data/human/adult/scenarios/patient/HemorrhageVaryingSeverity.json b/data/human/adult/scenarios/patient/HemorrhageVaryingSeverity.json index e9b76e0f145e3154d592b2643d8f206df93fd71b..a5084a12531a652e4d9a777e3ee284c9d8194680 100644 --- a/data/human/adult/scenarios/patient/HemorrhageVaryingSeverity.json +++ b/data/human/adult/scenarios/patient/HemorrhageVaryingSeverity.json @@ -64,7 +64,11 @@ { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "SystemicVascularResistance", "Unit": "mmHg s/mL"}, { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TotalHemorrhageRate", "Unit": "mL/s"}, - { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TotalHemorrhagedVolume", "Unit": "mL"} + { "DecimalFormat": { "Precision": 3 }, "Category": "Physiology", "PropertyName": "TotalHemorrhagedVolume", "Unit": "mL"}, + { "DecimalFormat": { "Precision": 3 }, "Category": "Action", "ActionName": "Hemorrhage", "CompartmentName": "RightLegVasculature", "PropertyName": "FlowRate", "Unit": "mL/s"}, + { "DecimalFormat": { "Precision": 3 }, "Category": "Action", "ActionName": "Hemorrhage", "CompartmentName": "RightLegVasculature", "PropertyName": "TotalBloodLost", "Unit": "mL"}, + { "DecimalFormat": { "Precision": 3 }, "Category": "Action", "ActionName": "Hemorrhage", "CompartmentName": "LeftLegVasculature", "PropertyName": "FlowRate", "Unit": "mL/s"}, + { "DecimalFormat": { "Precision": 3 }, "Category": "Action", "ActionName": "Hemorrhage", "CompartmentName": "LeftLegVasculature", "PropertyName": "TotalBloodLost", "Unit": "mL"} ] }, "AnyAction": [{ @@ -87,6 +91,17 @@ } } } + }, { + "PatientAction": { + "Hemorrhage": { + "Compartment": "LeftLegVasculature", + "Severity": { + "Scalar0To1": { + "Value": 0.0 + } + } + } + } }, { "AdvanceTime": { "Time": { diff --git a/data/human/adult/scenarios/showcase/EnvironmentExposure.json b/data/human/adult/scenarios/showcase/EnvironmentExposure.json index eff21764d4bb631c2d8469d620d479f45ade5265..09a3ed61a7ee7647fd7a82e3f7a8694d6487ac4c 100644 --- a/data/human/adult/scenarios/showcase/EnvironmentExposure.json +++ b/data/human/adult/scenarios/showcase/EnvironmentExposure.json @@ -1,7 +1,7 @@ { "Name": "EnvironmentExposure", "Description": "Showcase scenario: Patient is exposed to sub-zero temperatures and develops hypothermia.", - "PatientConfiguration": { "PatientFile": "Jane.json" }, + "PatientConfiguration": { "PatientFile": "Jane.json" }, "DataRequestManager": { "DataRequest": [{ "DecimalFormat": { diff --git a/src/cpp/cdm/CMakeLists.txt b/src/cpp/cdm/CMakeLists.txt index ea1594aee625ee2ce9fb1f438f2340fee8fd18e7..c42a05891ea437190c16e5d051ec0aa6a3c81fe1 100644 --- a/src/cpp/cdm/CMakeLists.txt +++ b/src/cpp/cdm/CMakeLists.txt @@ -114,7 +114,6 @@ add_library_ex(CommonDataModel patient/actions/SEBrainInjury.h patient/actions/SEBronchoconstriction.h patient/actions/SECardiacArrest.h - patient/actions/SEChestCompression.h patient/actions/SEChestCompressionForce.h patient/actions/SEChestCompressionForceScale.h patient/actions/SEChestOcclusiveDressing.h @@ -154,7 +153,6 @@ add_library_ex(CommonDataModel patient/assessments/SEUrinalysisMicroscopic.h patient/conditions/SEAcuteRespiratoryDistressSyndrome.h patient/conditions/SEChronicAnemia.h - patient/conditions/SEChronicHeartFailure.h patient/conditions/SEChronicObstructivePulmonaryDisease.h patient/conditions/SEChronicPericardialEffusion.h patient/conditions/SEChronicRenalStenosis.h @@ -454,7 +452,6 @@ add_library_ex(CommonDataModel patient/actions/SEBrainInjury.cpp patient/actions/SEBronchoconstriction.cpp patient/actions/SECardiacArrest.cpp - patient/actions/SEChestCompression.cpp patient/actions/SEChestCompressionForce.cpp patient/actions/SEChestCompressionForceScale.cpp patient/actions/SEChestOcclusiveDressing.cpp @@ -494,7 +491,6 @@ add_library_ex(CommonDataModel patient/assessments/SEUrinalysisMicroscopic.cpp patient/conditions/SEAcuteRespiratoryDistressSyndrome.cpp patient/conditions/SEChronicAnemia.cpp - patient/conditions/SEChronicHeartFailure.cpp patient/conditions/SEChronicObstructivePulmonaryDisease.cpp patient/conditions/SEChronicPericardialEffusion.cpp patient/conditions/SEChronicRenalStenosis.cpp diff --git a/src/cpp/cdm/compartment/SECompartmentNodes.h b/src/cpp/cdm/compartment/SECompartmentNodes.h index ae8c7cba5906203d6565173e7d9be8defd9f5900..030ef4f24c7b4f6f2bb63620c24d600ef56335fe 100644 --- a/src/cpp/cdm/compartment/SECompartmentNodes.h +++ b/src/cpp/cdm/compartment/SECompartmentNodes.h @@ -22,6 +22,13 @@ public: virtual void StateChange(); //analyze and cache for optimization virtual bool HasMapping() const { return !m_AllNodes.empty(); } + virtual bool HasMapping(const NodeType& n) const + { + for (auto mine : m_AllNodes) + if (&n == mine) + return true; + return false; + } virtual const std::vector& GetNodes() const { return m_AllNodes; } virtual const std::vector& GetQuantityNodes() const { return m_QuantityNodes; } virtual void RemoveNode(NodeType& node); diff --git a/src/cpp/cdm/engine/SEAction.cpp b/src/cpp/cdm/engine/SEAction.cpp index cb8c8fad6356ab1a0f64abf6c70126b054fe5684..c95e41f8fa46790a40d2ad062be7dddfbf5cbd3f 100644 --- a/src/cpp/cdm/engine/SEAction.cpp +++ b/src/cpp/cdm/engine/SEAction.cpp @@ -22,6 +22,7 @@ SEAction::~SEAction() void SEAction::Clear() { m_Comment=""; + m_Active = false; } std::string SEAction::GetComment() const diff --git a/src/cpp/cdm/engine/SEAction.h b/src/cpp/cdm/engine/SEAction.h index 826a33f1e2885dab96cf605fb2e37d080e39a63a..bf60c2f2fa486d3e056638fcfbbc08386106d3c0 100644 --- a/src/cpp/cdm/engine/SEAction.h +++ b/src/cpp/cdm/engine/SEAction.h @@ -17,9 +17,12 @@ public: /** Test if the action has all data it needs */ virtual bool IsValid() const { return true; } + /** Actions can be turned off or on with various data combinations * This method will encapsulate that logic in a single function */ - virtual bool IsActive() const { return IsValid(); } + virtual bool IsActive() const { return !m_Active ? false : IsValid(); } + virtual void Activate() { m_Active = true; } + virtual void Deactivate() { m_Active = false; } virtual std::string GetComment() const; virtual void SetComment(const std::string& comment); @@ -28,8 +31,10 @@ public: virtual void ToString(std::ostream &str)const=0; -protected: + virtual const SEScalar* GetScalar(const std::string& name)=0; +protected: + bool m_Active = true; std::string m_Comment; }; diff --git a/src/cpp/cdm/engine/SEActionManager.cpp b/src/cpp/cdm/engine/SEActionManager.cpp index 756d707d89cafb14654060d954d786a87ccc84f5..08d3fe08b45f70e6fd5156b43ea4ca6448687244 100644 --- a/src/cpp/cdm/engine/SEActionManager.cpp +++ b/src/cpp/cdm/engine/SEActionManager.cpp @@ -13,11 +13,11 @@ #include "substance/SESubstanceManager.h" #include "io/protobuf/PBEngine.h" -SEActionManager::SEActionManager(Logger* logger) : Loggable(logger) +SEActionManager::SEActionManager(SESubstanceManager& subMgr) : m_SubMgr(subMgr), Loggable(subMgr.GetLogger()) { - m_PatientActions = new SEPatientActionCollection(logger); - m_EnvironmentActions = new SEEnvironmentActionCollection(logger); - m_EquipmentActions = new SEEquipmentActionCollection(logger); + m_PatientActions = new SEPatientActionCollection(m_SubMgr); + m_EnvironmentActions = new SEEnvironmentActionCollection(m_SubMgr); + m_EquipmentActions = new SEEquipmentActionCollection(m_SubMgr); } SEActionManager::~SEActionManager() @@ -42,13 +42,13 @@ bool SEActionManager::SerializeToFile(const std::string& filename) const { return PBEngine::SerializeToFile(*this, filename); } -bool SEActionManager::SerializeFromString(const std::string& src, SerializationFormat m, SESubstanceManager& subMgr) +bool SEActionManager::SerializeFromString(const std::string& src, SerializationFormat m) { - return PBEngine::SerializeFromString(src, *this, m, subMgr); + return PBEngine::SerializeFromString(src, *this, m); } -bool SEActionManager::SerializeFromFile(const std::string& filename, SESubstanceManager& subMgr) +bool SEActionManager::SerializeFromFile(const std::string& filename) { - return PBEngine::SerializeFromFile(filename, *this, subMgr); + return PBEngine::SerializeFromFile(filename, *this); } // A raw serialize method @@ -64,7 +64,7 @@ bool SEActionManager::SerializeFromString(const std::string& src, std::vector(&action); if (pa != nullptr) - bRet = m_PatientActions->ProcessAction(*pa, subMgr); + bRet = m_PatientActions->ProcessAction(*pa); const SEEnvironmentAction* ea = dynamic_cast(&action); if (ea != nullptr) - bRet = m_EnvironmentActions->ProcessAction(*ea, subMgr); + bRet = m_EnvironmentActions->ProcessAction(*ea); const SEEquipmentAction* ia = dynamic_cast(&action); if (ia != nullptr) - bRet = m_EquipmentActions->ProcessAction(*ia, subMgr); + bRet = m_EquipmentActions->ProcessAction(*ia); if (!bRet) { @@ -100,3 +100,22 @@ void SEActionManager::GetAllActions(std::vector& actions) const m_EnvironmentActions->GetAllActions(actions); m_EquipmentActions->GetAllActions(actions); } + +const SEScalar* SEActionManager::GetScalar(const std::string& actionName, const std::string& cmptName, const std::string& substance, const std::string& property) +{ + const SEScalar* scalar; + + scalar = m_PatientActions->GetScalar(actionName,cmptName, substance,property); + if (scalar != nullptr) + return scalar; + + scalar = m_EnvironmentActions->GetScalar(actionName, cmptName, substance, property); + if (scalar != nullptr) + return scalar; + + scalar = m_EquipmentActions->GetScalar(actionName, cmptName, substance, property); + if (scalar != nullptr) + return scalar; + + return nullptr; +} diff --git a/src/cpp/cdm/engine/SEActionManager.h b/src/cpp/cdm/engine/SEActionManager.h index 587947fef9181813dbc6fe97efa4427b228486d2..23ff7f055476ebc7fa9ae2b146bea032989f41d0 100644 --- a/src/cpp/cdm/engine/SEActionManager.h +++ b/src/cpp/cdm/engine/SEActionManager.h @@ -13,19 +13,21 @@ class CDM_DECL SEActionManager : public Loggable friend class PBEngine;//friend the serialization class public: - SEActionManager(Logger* logger=nullptr); + SEActionManager(SESubstanceManager& subMgr); ~SEActionManager(); void Clear(); bool SerializeToString(std::string& output, SerializationFormat m) const; bool SerializeToFile(const std::string& filename) const; - bool SerializeFromString(const std::string& src, SerializationFormat m, SESubstanceManager& subMgr); - bool SerializeFromFile(const std::string& filename, SESubstanceManager& subMgr); + bool SerializeFromString(const std::string& src, SerializationFormat m); + bool SerializeFromFile(const std::string& filename); static bool SerializeFromString(const std::string& src, std::vector& dst, SerializationFormat m, const SESubstanceManager& subMgr); - bool ProcessAction(const SEAction& action, SESubstanceManager&);// Will make a copy + bool ProcessAction(const SEAction& action);// Will make a copy + + const SEScalar* GetScalar(const std::string& actionName, const std::string& cmptName, const std::string& substance, const std::string& property); SEPatientActionCollection& GetPatientActions() { return *m_PatientActions; } SEEnvironmentActionCollection& GetEnvironmentActions() { return *m_EnvironmentActions; } @@ -38,7 +40,7 @@ public: void GetAllActions(std::vector& v) const; protected: - + SESubstanceManager& m_SubMgr; SEPatientActionCollection* m_PatientActions; SEEnvironmentActionCollection* m_EnvironmentActions; SEEquipmentActionCollection* m_EquipmentActions; diff --git a/src/cpp/cdm/engine/SEAdvanceTime.cpp b/src/cpp/cdm/engine/SEAdvanceTime.cpp index e402801d7443e5b8182b3f62815f21d9ab9e2256..d9c8a20ea2cd89cb9e0dfcc81448058752b1bc63 100644 --- a/src/cpp/cdm/engine/SEAdvanceTime.cpp +++ b/src/cpp/cdm/engine/SEAdvanceTime.cpp @@ -26,13 +26,6 @@ bool SEAdvanceTime::IsValid() const return HasTime() && m_Time->IsValid(); } -void SEAdvanceTime::ToString(std::ostream &str) const -{ - if(HasComment()) - str<<"\n\tComment : "<IsValid(); @@ -48,4 +41,18 @@ double SEAdvanceTime::GetTime(const TimeUnit& unit) const if (m_Time == nullptr) return SEScalar::dNaN(); return m_Time->GetValue(unit); -} \ No newline at end of file +} + +void SEAdvanceTime::ToString(std::ostream& str) const +{ + if (HasComment()) + str << "\n\tComment : " << m_Comment; + str << "\n\tAdvance Time : " << m_Time; +} + +const SEScalar* SEAdvanceTime::GetScalar(const std::string& name) +{ + if (name.compare("Time") == 0) + return &GetTime(); + return nullptr; +} diff --git a/src/cpp/cdm/engine/SEAdvanceTime.h b/src/cpp/cdm/engine/SEAdvanceTime.h index fc9bbfc221ed4493b9ad8b63ee2722fc94e3d0f9..f1995073dad4c313ad8d118cd81943bf69bd66ea 100644 --- a/src/cpp/cdm/engine/SEAdvanceTime.h +++ b/src/cpp/cdm/engine/SEAdvanceTime.h @@ -16,12 +16,14 @@ public: virtual bool IsValid() const; - virtual void ToString(std::ostream &str) const; - virtual bool HasTime() const; virtual SEScalarTime& GetTime(); virtual double GetTime(const TimeUnit& unit) const; + virtual void ToString(std::ostream &str) const; + + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalarTime *m_Time; diff --git a/src/cpp/cdm/engine/SEAutoSerialization.cpp b/src/cpp/cdm/engine/SEAutoSerialization.cpp index a87fb58132942ac6e2e98ff62f53054f478d3610..ea616da0f820b61f82fc4d75f7dbcee2a3f170b4 100644 --- a/src/cpp/cdm/engine/SEAutoSerialization.cpp +++ b/src/cpp/cdm/engine/SEAutoSerialization.cpp @@ -20,7 +20,7 @@ SEAutoSerialization::~SEAutoSerialization() SAFE_DELETE(m_Period); m_PeriodTimeStamps = eSwitch::Off; m_AfterActions = eSwitch::Off; - m_AfterActions = eSwitch::Off; + m_ReloadState = eSwitch::Off; m_Directory = ""; m_FileName = ""; } @@ -30,16 +30,16 @@ void SEAutoSerialization::Clear() INVALIDATE_PROPERTY(m_Period); m_PeriodTimeStamps = eSwitch::Off; m_AfterActions = eSwitch::Off; - m_AfterActions = eSwitch::Off; + m_ReloadState = eSwitch::Off; m_Directory = ""; m_FileName = ""; } bool SEAutoSerialization::IsValid() const { - if (!HasPeriod()) + if (HasPeriod() && m_Period->IsNegative()) return false; - if (m_Period->IsNegative()) + else if (m_AfterActions == eSwitch::Off) return false; if (!HasDirectory()) return false; diff --git a/src/cpp/cdm/engine/SEAutoSerialization.h b/src/cpp/cdm/engine/SEAutoSerialization.h index 0dd565bde2074b0e82939a6c1790e5b0d19de4c5..de07c863fe7ad6d817b9b11f85a844a19dbed66d 100644 --- a/src/cpp/cdm/engine/SEAutoSerialization.h +++ b/src/cpp/cdm/engine/SEAutoSerialization.h @@ -39,10 +39,10 @@ public: protected: - SEScalarTime* m_Period; + SEScalarTime* m_Period; eSwitch m_PeriodTimeStamps; eSwitch m_AfterActions; eSwitch m_ReloadState; - std::string m_Directory; - std::string m_FileName; + std::string m_Directory; + std::string m_FileName; }; diff --git a/src/cpp/cdm/engine/SEConditionManager.cpp b/src/cpp/cdm/engine/SEConditionManager.cpp index f60611556d97cbd59f8b0470a268d31f248e65e3..00e912ea96464c5b93802f7d4761ebf2aafea2b2 100644 --- a/src/cpp/cdm/engine/SEConditionManager.cpp +++ b/src/cpp/cdm/engine/SEConditionManager.cpp @@ -7,7 +7,6 @@ #include "patient/conditions/SEAcuteRespiratoryDistressSyndrome.h" #include "patient/conditions/SEChronicAnemia.h" #include "patient/conditions/SEChronicObstructivePulmonaryDisease.h" -#include "patient/conditions/SEChronicHeartFailure.h" #include "patient/conditions/SEChronicPericardialEffusion.h" #include "patient/conditions/SEChronicRenalStenosis.h" #include "patient/conditions/SEChronicVentricularSystolicDysfunction.h" @@ -138,20 +137,6 @@ bool SEConditionManager::Copy(const SECondition& condition, const SESubstanceMan return true; } - const SEChronicHeartFailure* h = dynamic_cast(&condition); - if (h != nullptr) - { - // When we add more of these type, make sure to Clear then all out here - const SEChronicVentricularSystolicDysfunction* vsd = dynamic_cast(&condition); - if (vsd != nullptr) - { - GetChronicVentricularSystolicDysfunction().Copy(*vsd); - return true; - } - Error("Unknown Heart Failure condition"); - return false; - } - const SEChronicPericardialEffusion* pe = dynamic_cast(&condition); if (pe != nullptr) { @@ -166,6 +151,13 @@ bool SEConditionManager::Copy(const SECondition& condition, const SESubstanceMan return true; } + const SEChronicVentricularSystolicDysfunction* vsd = dynamic_cast(&condition); + if (vsd != nullptr) + { + GetChronicVentricularSystolicDysfunction().Copy(*vsd); + return true; + } + const SEConsumeMeal* g = dynamic_cast(&condition); if (g != nullptr) { diff --git a/src/cpp/cdm/engine/SEDataRequest.cpp b/src/cpp/cdm/engine/SEDataRequest.cpp index 6ad95d897a34f629764f3cae78316b37461241b3..9f3ec934b81a9ff8c7ef405c5a6a6dcd5a812010 100644 --- a/src/cpp/cdm/engine/SEDataRequest.cpp +++ b/src/cpp/cdm/engine/SEDataRequest.cpp @@ -10,6 +10,7 @@ SEDataRequest::SEDataRequest(const SEDataRequest& dr) { Set(dr); m_Category = dr.m_Category; + m_ActionName = dr.m_ActionName; m_CompartmentName = dr.m_CompartmentName; m_SubstanceName = dr.m_SubstanceName; m_PropertyName = dr.m_PropertyName; @@ -20,6 +21,7 @@ SEDataRequest::SEDataRequest(const SEDataRequest& dr) SEDataRequest::SEDataRequest(eDataRequest_Category category, const SEDecimalFormat* dfault) : SEDecimalFormat(dfault) { m_Category = category; + m_ActionName = ""; m_CompartmentName = ""; m_SubstanceName = ""; m_PropertyName=""; @@ -29,6 +31,7 @@ SEDataRequest::SEDataRequest(eDataRequest_Category category, const SEDecimalForm SEDataRequest::~SEDataRequest() { + m_ActionName = ""; m_CompartmentName = ""; m_SubstanceName = ""; m_PropertyName = ""; @@ -38,6 +41,7 @@ SEDataRequest::~SEDataRequest() void SEDataRequest::Clear() { + m_ActionName = ""; m_CompartmentName = ""; m_SubstanceName = ""; m_PropertyName=""; @@ -76,6 +80,12 @@ bool SEDataRequest::IsValid() std::cout << "Ignoring compartment and substance name on environment data request" << std::endl; return true; } + case eDataRequest_Category::Action: + { + if (!HasActionName()) + return false; + return true; + } case eDataRequest_Category::GasCompartment: case eDataRequest_Category::LiquidCompartment: case eDataRequest_Category::ThermalCompartment: @@ -104,7 +114,24 @@ size_t SEDataRequest::HashCode() const eDataRequest_Category SEDataRequest::GetCategory() const { - return m_Category; + return m_Category; +} + +std::string SEDataRequest::GetActionName() const +{ + return m_ActionName; +} +void SEDataRequest::SetActionName(const std::string& name) +{ + m_ActionName = name; +} +bool SEDataRequest::HasActionName() const +{ + return m_ActionName.empty() ? false : true; +} +void SEDataRequest::InvalidateActionName() +{ + m_ActionName = ""; } std::string SEDataRequest::GetCompartmentName() const diff --git a/src/cpp/cdm/engine/SEDataRequest.h b/src/cpp/cdm/engine/SEDataRequest.h index 86db78b19ce39748a40b383dbd012f6f3a139939..68c9ffeef35d097cf76e904ce965418fc82f476d 100644 --- a/src/cpp/cdm/engine/SEDataRequest.h +++ b/src/cpp/cdm/engine/SEDataRequest.h @@ -8,9 +8,9 @@ class SEDataRequestManager; #include "engine/SEDecimalFormat.h" enum class eDataRequest_Category { - Patient = 0, Physiology, Environment, GasCompartment, - LiquidCompartment, ThermalCompartment, TissueCompartment, Substance, - AnesthesiaMachine, ECG, Inhaler, MechanicalVentilator + Patient = 0, Physiology, Environment, Action, + GasCompartment, LiquidCompartment, ThermalCompartment, TissueCompartment, + Substance, AnesthesiaMachine, ECG, Inhaler, MechanicalVentilator }; extern const std::string& eDataRequest_Category_Name(eDataRequest_Category m); @@ -34,6 +34,12 @@ public: // The Request Category virtual eDataRequest_Category GetCategory() const; + // OPTIONAL The Action Name holding the property + virtual std::string GetActionName() const; + virtual void SetActionName(const std::string& name); + virtual bool HasActionName() const; + virtual void InvalidateActionName(); + // OPTIONAL The Compartment Name holding the property virtual std::string GetCompartmentName() const; virtual void SetCompartmentName(const std::string& name); @@ -70,6 +76,7 @@ public: protected: eDataRequest_Category m_Category; + std::string m_ActionName; std::string m_CompartmentName; std::string m_SubstanceName; std::string m_PropertyName; diff --git a/src/cpp/cdm/engine/SEDataRequestManager.cpp b/src/cpp/cdm/engine/SEDataRequestManager.cpp index 7948b8a032ea72bf22584840f74b825e475451ed..78b5917e05dcbefeed9b5dad2455538f4dc1e8bf 100644 --- a/src/cpp/cdm/engine/SEDataRequestManager.cpp +++ b/src/cpp/cdm/engine/SEDataRequestManager.cpp @@ -108,6 +108,9 @@ SEDataRequest* SEDataRequestManager::FindDataRequest(const SEDataRequest& dr) case eDataRequest_Category::Environment: my_dr = FindEnvironmentDataRequest(dr.GetPropertyName()); return my_dr; + case eDataRequest_Category::Action: + my_dr = FindActionDataRequest(dr.GetActionName(), dr.GetCompartmentName(), dr.GetSubstanceName(), dr.GetPropertyName()); + return my_dr; case eDataRequest_Category::GasCompartment: if(dr.HasSubstanceName()) my_dr = FindGasCompartmentDataRequest(dr.GetCompartmentName(), dr.GetSubstanceName(), dr.GetPropertyName()); @@ -245,6 +248,93 @@ SEDataRequest* SEDataRequestManager::FindEnvironmentDataRequest(const std::strin return nullptr; } +SEDataRequest& SEDataRequestManager::CreateActionDataRequest(const std::string& actionName, const std::string& property, const SEDecimalFormat* dfault) +{ + SEDataRequest* dr = FindActionDataRequest(actionName, "", "", property); + if (dr != nullptr) + return *dr; + dr = new SEDataRequest(eDataRequest_Category::Action, dfault); + m_Requests.push_back(dr); + dr->SetActionName(actionName); + dr->SetPropertyName(property); + return *dr; +} +SEDataRequest& SEDataRequestManager::CreateActionDataRequest(const std::string& actionName, const std::string& property, const CCompoundUnit& unit, const SEDecimalFormat* dfault) +{ + SEDataRequest* dr = FindActionDataRequest(actionName, "", "", property); + if (dr != nullptr) + return *dr; + dr = new SEDataRequest(eDataRequest_Category::Action, dfault); + m_Requests.push_back(dr); + dr->SetActionName(actionName); + dr->SetPropertyName(property); + dr->SetUnit(unit); + return *dr; +} +SEDataRequest& SEDataRequestManager::CreateActionCompartmentDataRequest(const std::string& actionName, const std::string& cmptName, const std::string& property, const SEDecimalFormat* dfault) +{ + SEDataRequest* dr = FindActionDataRequest(actionName, cmptName, "", property); + if (dr != nullptr) + return *dr; + dr = new SEDataRequest(eDataRequest_Category::Action, dfault); + m_Requests.push_back(dr); + dr->SetActionName(actionName); + dr->SetCompartmentName(cmptName); + dr->SetPropertyName(property); + return *dr; +} +SEDataRequest& SEDataRequestManager::CreateActionCompartmentDataRequest(const std::string& actionName, const std::string& cmptName, const std::string& property, const CCompoundUnit& unit, const SEDecimalFormat* dfault) +{ + SEDataRequest* dr = FindActionDataRequest(actionName, cmptName, "", property); + if (dr != nullptr) + return *dr; + dr = new SEDataRequest(eDataRequest_Category::Action, dfault); + m_Requests.push_back(dr); + dr->SetActionName(actionName); + dr->SetCompartmentName(cmptName); + dr->SetPropertyName(property); + dr->SetUnit(unit); + return *dr; +} +SEDataRequest& SEDataRequestManager::CreateActionSubstanceDataRequest(const std::string& actionName, const std::string& substance, const std::string& property, const SEDecimalFormat* dfault) +{ + SEDataRequest* dr = FindActionDataRequest(actionName, "", substance, property); + if (dr != nullptr) + return *dr; + dr = new SEDataRequest(eDataRequest_Category::Action, dfault); + m_Requests.push_back(dr); + dr->SetActionName(actionName); + dr->SetSubstanceName(substance); + dr->SetPropertyName(property); + return *dr; +} +SEDataRequest& SEDataRequestManager::CreateActionSubstanceDataRequest(const std::string& actionName, const std::string& substance, const std::string& property, const CCompoundUnit& unit, const SEDecimalFormat* dfault) +{ + SEDataRequest* dr = FindActionDataRequest(actionName, "", substance, property); + if (dr != nullptr) + return *dr; + dr = new SEDataRequest(eDataRequest_Category::Action, dfault); + m_Requests.push_back(dr); + dr->SetActionName(actionName); + dr->SetSubstanceName(substance); + dr->SetPropertyName(property); + dr->SetUnit(unit); + return *dr; +} +SEDataRequest* SEDataRequestManager::FindActionDataRequest(const std::string& actionName, const std::string& cmptName, const std::string& substance, const std::string& property) +{ + for (SEDataRequest* dr : m_Requests) + { + if (dr->GetCategory() == eDataRequest_Category::Action && + dr->GetPropertyName() == property && + dr->GetActionName() == actionName && + dr->GetCompartmentName() == cmptName && + dr->GetSubstanceName() == substance) + return dr; + } + return nullptr; +} + SEDataRequest& SEDataRequestManager::CreateGasCompartmentDataRequest(const std::string& cmptName, const std::string& property, const SEDecimalFormat* dfault) { SEDataRequest* dr = FindGasCompartmentDataRequest(cmptName, property); @@ -305,7 +395,7 @@ SEDataRequest& SEDataRequestManager::CreateGasCompartmentDataRequest(const std:: dr->SetUnit(unit); return *dr; } -SEDataRequest* SEDataRequestManager::FindGasCompartmentDataRequest(const std::string& cmptName, const std::string& substance, const std::string property) +SEDataRequest* SEDataRequestManager::FindGasCompartmentDataRequest(const std::string& cmptName, const std::string& substance, const std::string& property) { for (SEDataRequest* dr : m_Requests) { @@ -378,7 +468,7 @@ SEDataRequest& SEDataRequestManager::CreateLiquidCompartmentDataRequest(const st dr->SetUnit(unit); return *dr; } -SEDataRequest* SEDataRequestManager::FindLiquidCompartmentDataRequest(const std::string& cmptName, const std::string& substance, const std::string property) +SEDataRequest* SEDataRequestManager::FindLiquidCompartmentDataRequest(const std::string& cmptName, const std::string& substance, const std::string& property) { for (SEDataRequest* dr : m_Requests) { diff --git a/src/cpp/cdm/engine/SEDataRequestManager.h b/src/cpp/cdm/engine/SEDataRequestManager.h index ee06cbceb028722f6d88666068facc689091d17d..39e2964b934e46532076b0d467ec22def13f8f32 100644 --- a/src/cpp/cdm/engine/SEDataRequestManager.h +++ b/src/cpp/cdm/engine/SEDataRequestManager.h @@ -51,6 +51,13 @@ public: SEDataRequest& CreateEnvironmentDataRequest(const std::string& property, const SEDecimalFormat* dfault = nullptr); SEDataRequest& CreateEnvironmentDataRequest(const std::string& property, const CCompoundUnit& unit, const SEDecimalFormat* dfault = nullptr); + SEDataRequest& CreateActionDataRequest(const std::string& actionName, const std::string& property, const SEDecimalFormat* dfault = nullptr); + SEDataRequest& CreateActionDataRequest(const std::string& actionName, const std::string& property, const CCompoundUnit& unit, const SEDecimalFormat* dfault = nullptr); + SEDataRequest& CreateActionCompartmentDataRequest(const std::string& actionName, const std::string& cmptName, const std::string& property, const SEDecimalFormat* dfault = nullptr); + SEDataRequest& CreateActionCompartmentDataRequest(const std::string& actionName, const std::string& cmptName, const std::string& property, const CCompoundUnit& unit, const SEDecimalFormat* dfault = nullptr); + SEDataRequest& CreateActionSubstanceDataRequest(const std::string& actionName, const std::string& substance, const std::string& property, const SEDecimalFormat* dfault = nullptr); + SEDataRequest& CreateActionSubstanceDataRequest(const std::string& actionName, const std::string& substance, const std::string& property, const CCompoundUnit& unit, const SEDecimalFormat* dfault = nullptr); + SEDataRequest& CreateGasCompartmentDataRequest(const std::string& cmptName, const std::string& property, const SEDecimalFormat* dfault = nullptr); SEDataRequest& CreateGasCompartmentDataRequest(const std::string& cmptName, const std::string& property, const CCompoundUnit& unit, const SEDecimalFormat* dfault = nullptr); SEDataRequest& CreateGasCompartmentDataRequest(const std::string& cmptName, const std::string& substance, const std::string& property, const SEDecimalFormat* dfault = nullptr); @@ -88,10 +95,11 @@ protected: SEDataRequest* FindPatientDataRequest(const std::string& property); SEDataRequest* FindPhysiologyDataRequest(const std::string& property); SEDataRequest* FindEnvironmentDataRequest(const std::string& property); + SEDataRequest* FindActionDataRequest(const std::string& actionName, const std::string& cmptName, const std::string& substance, const std::string& property); SEDataRequest* FindGasCompartmentDataRequest(const std::string& cmptName, const std::string& property); - SEDataRequest* FindGasCompartmentDataRequest(const std::string& cmptName, const std::string& substance, const std::string property); + SEDataRequest* FindGasCompartmentDataRequest(const std::string& cmptName, const std::string& substance, const std::string& property); SEDataRequest* FindLiquidCompartmentDataRequest(const std::string& cmptName, const std::string& property); - SEDataRequest* FindLiquidCompartmentDataRequest(const std::string& cmptName, const std::string& substance, const std::string property); + SEDataRequest* FindLiquidCompartmentDataRequest(const std::string& cmptName, const std::string& substance, const std::string& property); SEDataRequest* FindThermalCompartmentDataRequest(const std::string& cmptName, const std::string& property); SEDataRequest* FindTissueCompartmentDataRequest(const std::string& cmptName, const std::string& property); SEDataRequest* FindSubstanceDataRequest(const std::string& substance, const std::string& property); diff --git a/src/cpp/cdm/engine/SEEngineTracker.cpp b/src/cpp/cdm/engine/SEEngineTracker.cpp index e947ebc6e5d9b1a9c73b2420a07b9ba0fa9d3c63..3d97285659cd5b5a0a9620309f2ad476ac1b6f93 100644 --- a/src/cpp/cdm/engine/SEEngineTracker.cpp +++ b/src/cpp/cdm/engine/SEEngineTracker.cpp @@ -3,6 +3,7 @@ #include "stdafx.h" #include "engine/SEEngineTracker.h" +#include "engine/SEActionManager.h" #include "engine/SEDataRequest.h" #include "engine/SEDataRequestManager.h" #include "PhysiologyEngine.h" @@ -70,8 +71,8 @@ std::string Space2Underscore(const std::string& str) return s; } -SEEngineTracker::SEEngineTracker(SEPatient& p, SESubstanceManager& s, SECompartmentManager& c, Logger* logger) : Loggable(logger), - m_Patient(p), m_SubMgr(s), m_CmptMgr(c) +SEEngineTracker::SEEngineTracker(SEPatient& p, SEActionManager& a, SESubstanceManager& s, SECompartmentManager& c, Logger* logger) : Loggable(logger), + m_Patient(p), m_ActionMgr(a), m_SubMgr(s), m_CmptMgr(c) { m_DataTrack = new DataTrack(logger); m_DataRequestMgr = new SEDataRequestManager(logger); @@ -162,6 +163,7 @@ void SEEngineTracker::SetupRequests() bool isOpen = m_ResultsStream.is_open(); if (!isOpen || m_ForceConnection) {// Process/Hook up all requests with their associated scalers + DELETE_MAP_SECOND(m_Request2Scalar);// Get our scalars again for (SEDataRequest* dr : m_DataRequestMgr->GetDataRequests()) { if (!TrackRequest(*dr)) @@ -270,6 +272,42 @@ bool SEEngineTracker::TrackRequest(SEDataRequest& dr) m_DataTrack->SetFormatting(ds->Heading, dr); return success; } + case eDataRequest_Category::Action: + { + if (dr.HasCompartmentName() && dr.HasSubstanceName()) + { + if (!dr.GetUnit()) + m_ss << dr.GetActionName() << "-" << dr.GetCompartmentName() << "-" << dr.GetSubstanceName() << "-" << dr.GetPropertyName(); + else + m_ss << dr.GetActionName() << "-" << dr.GetCompartmentName() << "-" << dr.GetSubstanceName() << "-" << dr.GetPropertyName() << "(" << *dr.GetUnit() << ")"; + } + else if (dr.HasCompartmentName()) + { + if (!dr.GetUnit()) + m_ss << dr.GetActionName() << "-" << dr.GetCompartmentName() << "-" << dr.GetPropertyName(); + else + m_ss << dr.GetActionName() << "-" << dr.GetCompartmentName() << "-" << dr.GetPropertyName() << "(" << *dr.GetUnit() << ")"; + } + else if (dr.HasSubstanceName()) + { + if (!dr.GetUnit()) + m_ss << dr.GetActionName() << "-" << dr.GetSubstanceName() << "-" << dr.GetPropertyName(); + else + m_ss << dr.GetActionName() << "-" << dr.GetSubstanceName() << "-" << dr.GetPropertyName() << "(" << *dr.GetUnit() << ")"; + } + else + { + if (!dr.GetUnit()) + m_ss << dr.GetActionName() << "-" << dr.GetPropertyName(); + else + m_ss << dr.GetActionName() << "-" << dr.GetPropertyName() << "(" << *dr.GetUnit() << ")"; + } + ds->Heading = Space2Underscore(m_ss.str()); + m_ss.str("");//Reset Buffer + ds->idx = m_DataTrack->Probe(ds->Heading, 0); + m_DataTrack->SetFormatting(ds->Heading, dr); + return success; + } case eDataRequest_Category::GasCompartment: case eDataRequest_Category::LiquidCompartment: case eDataRequest_Category::ThermalCompartment: @@ -356,6 +394,11 @@ bool SEEngineTracker::ConnectRequest(SEDataRequest& dr, SEDataRequestScalar& ds) Error("Cannot track environment data as no environment was provide"); break; } + case eDataRequest_Category::Action: + { + s = m_ActionMgr.GetScalar(dr.GetActionName(), dr.GetCompartmentName(), dr.GetSubstanceName(), propertyName); + break; + } case eDataRequest_Category::AnesthesiaMachine: { if (m_AnesthesiaMachine != nullptr) diff --git a/src/cpp/cdm/engine/SEEngineTracker.h b/src/cpp/cdm/engine/SEEngineTracker.h index fb9b2f720b638c5abddfd323adfac7c0b198a5ff..9e0e9cfe8e3033fda64e914a4225ef6442e7d8e8 100644 --- a/src/cpp/cdm/engine/SEEngineTracker.h +++ b/src/cpp/cdm/engine/SEEngineTracker.h @@ -8,6 +8,7 @@ class SESystem; class SEPatient; class SEEnvironment; class PhysiologyEngine; +class SEActionManager; class SESubstanceManager; class SECompartmentManager; class SEDataRequest; @@ -63,12 +64,13 @@ protected: class CDM_DECL SEEngineTracker : public Loggable { public: - SEEngineTracker(SEPatient&, SESubstanceManager&, SECompartmentManager&, Logger* logger=nullptr); + SEEngineTracker(SEPatient&, SEActionManager&, SESubstanceManager&, SECompartmentManager&, Logger* logger=nullptr); virtual ~SEEngineTracker(); void Clear();// Remove all requests and close the results file DataTrack& GetDataTrack(); + SEActionManager& GetActionManager() { return m_ActionMgr; } SESubstanceManager& GetSubstanceManager() { return m_SubMgr; } SEDataRequestManager& GetDataRequestManager() { return *m_DataRequestMgr; } @@ -103,6 +105,7 @@ protected: SEDataRequestManager* m_DataRequestMgr; SEPatient& m_Patient; + SEActionManager& m_ActionMgr; SESubstanceManager& m_SubMgr; SECompartmentManager& m_CmptMgr; diff --git a/src/cpp/cdm/engine/SEEnvironmentActionCollection.cpp b/src/cpp/cdm/engine/SEEnvironmentActionCollection.cpp index fa4c2d55d14b3f8924cf6d008cf0d5d268a637b6..e8992c00143498081312bdaf55bc909030c7f347 100644 --- a/src/cpp/cdm/engine/SEEnvironmentActionCollection.cpp +++ b/src/cpp/cdm/engine/SEEnvironmentActionCollection.cpp @@ -15,7 +15,7 @@ #include "properties/SEScalarPressure.h" #include "properties/SEScalarTemperature.h" -SEEnvironmentActionCollection::SEEnvironmentActionCollection(Logger* logger) : Loggable(logger) +SEEnvironmentActionCollection::SEEnvironmentActionCollection(SESubstanceManager& subMgr) : m_SubMgr(subMgr), Loggable(subMgr.GetLogger()) { m_ChangeEnvironmentalConditions = nullptr; m_ThermalApplication = nullptr; @@ -32,14 +32,13 @@ void SEEnvironmentActionCollection::Clear() RemoveThermalApplication(); } -bool SEEnvironmentActionCollection::ProcessAction(const SEEnvironmentAction& action, SESubstanceManager& subMgr) +bool SEEnvironmentActionCollection::ProcessAction(const SEEnvironmentAction& action) { const SEChangeEnvironmentalConditions* conditions = dynamic_cast(&action); if (conditions != nullptr) { - if (m_ChangeEnvironmentalConditions == nullptr) - m_ChangeEnvironmentalConditions = new SEChangeEnvironmentalConditions(GetLogger()); - m_ChangeEnvironmentalConditions->Copy(*conditions, subMgr); + GetChangeEnvironmentalConditions().Copy(*conditions, m_SubMgr, true); + m_ChangeEnvironmentalConditions->Activate(); if (!m_ChangeEnvironmentalConditions->IsActive()) RemoveChangeEnvironmentalConditions(); return true; @@ -48,9 +47,8 @@ bool SEEnvironmentActionCollection::ProcessAction(const SEEnvironmentAction& act const SEThermalApplication *thermal = dynamic_cast(&action); if (thermal != nullptr) { - if (m_ThermalApplication == nullptr) - m_ThermalApplication = new SEThermalApplication(); - m_ThermalApplication->Copy(*thermal); + GetThermalApplication().Copy(*thermal, true); + m_ThermalApplication->Activate(); if (!m_ThermalApplication->IsActive()) RemoveThermalApplication(); return true; @@ -63,11 +61,13 @@ bool SEEnvironmentActionCollection::ProcessAction(const SEEnvironmentAction& act bool SEEnvironmentActionCollection::HasChangeEnvironmentalConditions() const { - return m_ChangeEnvironmentalConditions == nullptr ? false : true; + return m_ChangeEnvironmentalConditions == nullptr ? false : m_ChangeEnvironmentalConditions->IsActive(); } -SEChangeEnvironmentalConditions* SEEnvironmentActionCollection::GetChangeEnvironmentalConditions() +SEChangeEnvironmentalConditions& SEEnvironmentActionCollection::GetChangeEnvironmentalConditions() { - return m_ChangeEnvironmentalConditions; + if (m_ChangeEnvironmentalConditions == nullptr) + m_ChangeEnvironmentalConditions = new SEChangeEnvironmentalConditions(); + return *m_ChangeEnvironmentalConditions; } const SEChangeEnvironmentalConditions* SEEnvironmentActionCollection::GetChangeEnvironmentalConditions() const { @@ -75,16 +75,19 @@ const SEChangeEnvironmentalConditions* SEEnvironmentActionCollection::GetChangeE } void SEEnvironmentActionCollection::RemoveChangeEnvironmentalConditions() { - SAFE_DELETE(m_ChangeEnvironmentalConditions); + if (m_ChangeEnvironmentalConditions) + m_ChangeEnvironmentalConditions->Deactivate(); } bool SEEnvironmentActionCollection::HasThermalApplication() const { - return m_ThermalApplication != nullptr; + return m_ThermalApplication == nullptr ? false : m_ThermalApplication->IsActive(); } -SEThermalApplication* SEEnvironmentActionCollection::GetThermalApplication() +SEThermalApplication& SEEnvironmentActionCollection::GetThermalApplication() { - return m_ThermalApplication; + if (m_ThermalApplication == nullptr) + m_ThermalApplication = new SEThermalApplication(); + return *m_ThermalApplication; } const SEThermalApplication* SEEnvironmentActionCollection::GetThermalApplication() const { @@ -92,7 +95,8 @@ const SEThermalApplication* SEEnvironmentActionCollection::GetThermalApplication } void SEEnvironmentActionCollection::RemoveThermalApplication() { - SAFE_DELETE(m_ThermalApplication); + if (m_ThermalApplication) + m_ThermalApplication->Deactivate(); } void SEEnvironmentActionCollection::GetAllActions(std::vector& actions) const @@ -101,4 +105,14 @@ void SEEnvironmentActionCollection::GetAllActions(std::vector& actions.push_back(GetChangeEnvironmentalConditions()); if (HasThermalApplication()) actions.push_back(GetThermalApplication()); -} \ No newline at end of file +} + +const SEScalar* SEEnvironmentActionCollection::GetScalar(const std::string& actionName, const std::string& cmptName, const std::string& substance, const std::string& property) +{ + if (actionName == "ChangeEnvironmentalConditions") + return GetChangeEnvironmentalConditions().GetScalar(property); + if (actionName == "ThermalApplication") + return GetThermalApplication().GetScalar(property); + + return nullptr; +} diff --git a/src/cpp/cdm/engine/SEEnvironmentActionCollection.h b/src/cpp/cdm/engine/SEEnvironmentActionCollection.h index 7a4858f5cb06b3ef335a92e4e8db0c4f7e963b85..258cef8653d2197496cd0516d4418c819f5e9dbf 100644 --- a/src/cpp/cdm/engine/SEEnvironmentActionCollection.h +++ b/src/cpp/cdm/engine/SEEnvironmentActionCollection.h @@ -14,26 +14,28 @@ class CDM_DECL SEEnvironmentActionCollection : public Loggable friend class PBEngine;//friend the serialization class friend class SEActionManager; protected: - SEEnvironmentActionCollection(Logger* logger=nullptr); + SEEnvironmentActionCollection(SESubstanceManager& subMgr); public: ~SEEnvironmentActionCollection(); bool HasChangeEnvironmentalConditions() const; - SEChangeEnvironmentalConditions* GetChangeEnvironmentalConditions(); + SEChangeEnvironmentalConditions& GetChangeEnvironmentalConditions(); const SEChangeEnvironmentalConditions* GetChangeEnvironmentalConditions() const; void RemoveChangeEnvironmentalConditions(); bool HasThermalApplication() const; - SEThermalApplication* GetThermalApplication(); + SEThermalApplication& GetThermalApplication(); const SEThermalApplication* GetThermalApplication() const; void RemoveThermalApplication(); void GetAllActions(std::vector& v) const; + const SEScalar* GetScalar(const std::string& actionName, const std::string& cmptName, const std::string& substance, const std::string& property); protected: void Clear(); - bool ProcessAction(const SEEnvironmentAction& action, SESubstanceManager&); + bool ProcessAction(const SEEnvironmentAction& action); + SESubstanceManager& m_SubMgr; SEChangeEnvironmentalConditions* m_ChangeEnvironmentalConditions; SEThermalApplication* m_ThermalApplication; }; diff --git a/src/cpp/cdm/engine/SEEquipmentActionCollection.cpp b/src/cpp/cdm/engine/SEEquipmentActionCollection.cpp index e369b259d8e334298aec907768d3d2bb391c64c3..c01f077ad0a8614f557ebc8242d34896b8709a98 100644 --- a/src/cpp/cdm/engine/SEEquipmentActionCollection.cpp +++ b/src/cpp/cdm/engine/SEEquipmentActionCollection.cpp @@ -30,7 +30,7 @@ #include "properties/SEScalarPressure.h" #include "properties/SEScalarVolumePerTime.h" -SEEquipmentActionCollection::SEEquipmentActionCollection(Logger* logger) : Loggable(logger) +SEEquipmentActionCollection::SEEquipmentActionCollection(SESubstanceManager& subMgr) : m_SubMgr(subMgr), Loggable(subMgr.GetLogger()) { m_AnesthesiaMachineConfiguration = nullptr; m_InhalerConfiguration = nullptr; @@ -78,7 +78,7 @@ void SEEquipmentActionCollection::Clear() RemoveAnesthesiaMachineYPieceDisconnect(); } -bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, SESubstanceManager& subMgr) +bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action) { const SEMechanicalVentilatorAction* mva = dynamic_cast(&action); if (mva != nullptr) @@ -86,9 +86,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEMechanicalVentilatorConfiguration* config = dynamic_cast(&action); if (config != nullptr) { - if (m_MechanicalVentilatorConfiguration == nullptr) - m_MechanicalVentilatorConfiguration = new SEMechanicalVentilatorConfiguration(GetLogger()); - m_MechanicalVentilatorConfiguration->Copy(*config, subMgr); + GetMechanicalVentilatorConfiguration().Copy(*config, m_SubMgr, true); + m_MechanicalVentilatorConfiguration->Activate(); if (!m_MechanicalVentilatorConfiguration->IsActive()) RemoveMechanicalVentilatorConfiguration(); return true; @@ -101,9 +100,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineConfiguration* config = dynamic_cast(&action); if (config != nullptr) { - if (m_AnesthesiaMachineConfiguration == nullptr) - m_AnesthesiaMachineConfiguration = new SEAnesthesiaMachineConfiguration(GetLogger()); - m_AnesthesiaMachineConfiguration->Copy(*config, subMgr); + GetAnesthesiaMachineConfiguration().Copy(*config, m_SubMgr, true); + m_AnesthesiaMachineConfiguration->Activate(); if (!m_AnesthesiaMachineConfiguration->IsActive()) RemoveAnesthesiaMachineConfiguration(); return true; @@ -112,9 +110,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineOxygenTankPressureLoss* O2Tank = dynamic_cast(&action); if (O2Tank != nullptr) { - if (m_AnesthesiaMachineOxygenTankPressureLoss == nullptr) - m_AnesthesiaMachineOxygenTankPressureLoss = new SEAnesthesiaMachineOxygenTankPressureLoss(); - m_AnesthesiaMachineOxygenTankPressureLoss->Copy(*O2Tank); + GetAnesthesiaMachineOxygenTankPressureLoss().Copy(*O2Tank, true); + m_AnesthesiaMachineOxygenTankPressureLoss->Activate(); if (!m_AnesthesiaMachineOxygenTankPressureLoss->IsActive()) RemoveAnesthesiaMachineOxygenTankPressureLoss(); return true; @@ -123,9 +120,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineOxygenWallPortPressureLoss* O2Wall = dynamic_cast(&action); if (O2Wall != nullptr) { - if (m_AnesthesiaMachineOxygenWallPortPressureLoss == nullptr) - m_AnesthesiaMachineOxygenWallPortPressureLoss = new SEAnesthesiaMachineOxygenWallPortPressureLoss(); - m_AnesthesiaMachineOxygenWallPortPressureLoss->Copy(*O2Wall); + GetAnesthesiaMachineOxygenWallPortPressureLoss().Copy(*O2Wall, true); + m_AnesthesiaMachineOxygenWallPortPressureLoss->Activate(); if (!m_AnesthesiaMachineOxygenWallPortPressureLoss->IsActive()) RemoveAnesthesiaMachineOxygenWallPortPressureLoss(); return true; @@ -134,9 +130,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineExpiratoryValveLeak* eLeak = dynamic_cast(&action); if (eLeak != nullptr) { - if (m_AnesthesiaMachineExpiratoryValveLeak == nullptr) - m_AnesthesiaMachineExpiratoryValveLeak = new SEAnesthesiaMachineExpiratoryValveLeak(); - m_AnesthesiaMachineExpiratoryValveLeak->Copy(*eLeak); + GetAnesthesiaMachineExpiratoryValveLeak().Copy(*eLeak, true); + m_AnesthesiaMachineExpiratoryValveLeak->Activate(); if (!m_AnesthesiaMachineExpiratoryValveLeak->IsActive()) RemoveAnesthesiaMachineExpiratoryValveLeak(); return true; @@ -145,9 +140,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineExpiratoryValveObstruction* eOb = dynamic_cast(&action); if (eOb != nullptr) { - if (m_AnesthesiaMachineExpiratoryValveObstruction == nullptr) - m_AnesthesiaMachineExpiratoryValveObstruction = new SEAnesthesiaMachineExpiratoryValveObstruction(); - m_AnesthesiaMachineExpiratoryValveObstruction->Copy(*eOb); + GetAnesthesiaMachineExpiratoryValveObstruction().Copy(*eOb, true); + m_AnesthesiaMachineExpiratoryValveObstruction->Activate(); if (!m_AnesthesiaMachineExpiratoryValveObstruction->IsActive()) RemoveAnesthesiaMachineExpiratoryValveObstruction(); return true; @@ -156,9 +150,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineInspiratoryValveLeak* iLeak = dynamic_cast(&action); if (iLeak != nullptr) { - if (m_AnesthesiaMachineInspiratoryValveLeak == nullptr) - m_AnesthesiaMachineInspiratoryValveLeak = new SEAnesthesiaMachineInspiratoryValveLeak(); - m_AnesthesiaMachineInspiratoryValveLeak->Copy(*iLeak); + GetAnesthesiaMachineInspiratoryValveLeak().Copy(*iLeak, true); + m_AnesthesiaMachineInspiratoryValveLeak->Activate(); if (!m_AnesthesiaMachineInspiratoryValveLeak->IsActive()) RemoveAnesthesiaMachineInspiratoryValveLeak(); return true; @@ -167,9 +160,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineInspiratoryValveObstruction* iOb = dynamic_cast(&action); if (iOb != nullptr) { - if (m_AnesthesiaMachineInspiratoryValveObstruction == nullptr) - m_AnesthesiaMachineInspiratoryValveObstruction = new SEAnesthesiaMachineInspiratoryValveObstruction(); - m_AnesthesiaMachineInspiratoryValveObstruction->Copy(*iOb); + GetAnesthesiaMachineInspiratoryValveObstruction().Copy(*iOb, true); + m_AnesthesiaMachineInspiratoryValveObstruction->Activate(); if (!m_AnesthesiaMachineInspiratoryValveObstruction->IsActive()) RemoveAnesthesiaMachineInspiratoryValveObstruction(); return true; @@ -178,9 +170,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineMaskLeak* mask = dynamic_cast(&action); if (mask != nullptr) { - if (m_AnesthesiaMachineMaskLeak == nullptr) - m_AnesthesiaMachineMaskLeak = new SEAnesthesiaMachineMaskLeak(); - m_AnesthesiaMachineMaskLeak->Copy(*mask); + GetAnesthesiaMachineMaskLeak().Copy(*mask, true); + m_AnesthesiaMachineMaskLeak->Activate(); if (!m_AnesthesiaMachineMaskLeak->IsActive()) RemoveAnesthesiaMachineMaskLeak(); return true; @@ -189,9 +180,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineSodaLimeFailure* soda = dynamic_cast(&action); if (soda != nullptr) { - if (m_AnesthesiaMachineSodaLimeFailure == nullptr) - m_AnesthesiaMachineSodaLimeFailure = new SEAnesthesiaMachineSodaLimeFailure(); - m_AnesthesiaMachineSodaLimeFailure->Copy(*soda); + GetAnesthesiaMachineSodaLimeFailure().Copy(*soda, true); + m_AnesthesiaMachineSodaLimeFailure->Activate(); if (!m_AnesthesiaMachineSodaLimeFailure->IsActive()) RemoveAnesthesiaMachineSodaLimeFailure(); return true; @@ -200,9 +190,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineTubeCuffLeak* tube = dynamic_cast(&action); if (tube != nullptr) { - if (m_AnesthesiaMachineTubeCuffLeak == nullptr) - m_AnesthesiaMachineTubeCuffLeak = new SEAnesthesiaMachineTubeCuffLeak(); - m_AnesthesiaMachineTubeCuffLeak->Copy(*tube); + GetAnesthesiaMachineTubeCuffLeak().Copy(*tube, true); + m_AnesthesiaMachineTubeCuffLeak->Activate(); if (!m_AnesthesiaMachineTubeCuffLeak->IsActive()) RemoveAnesthesiaMachineTubeCuffLeak(); return true; @@ -211,9 +200,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineVaporizerFailure* vFail = dynamic_cast(&action); if (vFail != nullptr) { - if (m_AnesthesiaMachineVaporizerFailure == nullptr) - m_AnesthesiaMachineVaporizerFailure = new SEAnesthesiaMachineVaporizerFailure(); - m_AnesthesiaMachineVaporizerFailure->Copy(*vFail); + GetAnesthesiaMachineVaporizerFailure().Copy(*vFail, true); + m_AnesthesiaMachineVaporizerFailure->Activate(); if (!m_AnesthesiaMachineVaporizerFailure->IsActive()) RemoveAnesthesiaMachineVaporizerFailure(); return true; @@ -222,9 +210,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineVentilatorPressureLoss* vLoss = dynamic_cast(&action); if (vLoss != nullptr) { - if (m_AnesthesiaMachineVentilatorPressureLoss == nullptr) - m_AnesthesiaMachineVentilatorPressureLoss = new SEAnesthesiaMachineVentilatorPressureLoss(); - m_AnesthesiaMachineVentilatorPressureLoss->Copy(*vLoss); + GetAnesthesiaMachineVentilatorPressureLoss().Copy(*vLoss, true); + m_AnesthesiaMachineVentilatorPressureLoss->Activate(); if (!m_AnesthesiaMachineVentilatorPressureLoss->IsActive()) RemoveAnesthesiaMachineVentilatorPressureLoss(); return true; @@ -233,9 +220,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEAnesthesiaMachineYPieceDisconnect* Y = dynamic_cast(&action); if (Y != nullptr) { - if (m_AnesthesiaMachineYPieceDisconnect == nullptr) - m_AnesthesiaMachineYPieceDisconnect = new SEAnesthesiaMachineYPieceDisconnect(); - m_AnesthesiaMachineYPieceDisconnect->Copy(*Y); + GetAnesthesiaMachineYPieceDisconnect().Copy(*Y, true); + m_AnesthesiaMachineYPieceDisconnect->Activate(); if (!m_AnesthesiaMachineYPieceDisconnect->IsActive()) RemoveAnesthesiaMachineYPieceDisconnect(); return true; @@ -248,9 +234,8 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, const SEInhalerConfiguration* config = dynamic_cast(&action); if (config != nullptr) { - if (m_InhalerConfiguration == nullptr) - m_InhalerConfiguration = new SEInhalerConfiguration(GetLogger()); - m_InhalerConfiguration->Copy(*config, subMgr); + GetInhalerConfiguration().Copy(*config, m_SubMgr, true); + m_InhalerConfiguration->Activate(); if (!m_InhalerConfiguration->IsActive()) RemoveInhalerConfiguration(); return true; @@ -264,11 +249,13 @@ bool SEEquipmentActionCollection::ProcessAction(const SEEquipmentAction& action, bool SEEquipmentActionCollection::HasAnesthesiaMachineConfiguration() const { - return m_AnesthesiaMachineConfiguration == nullptr ? false : true; + return m_AnesthesiaMachineConfiguration == nullptr ? false : m_AnesthesiaMachineConfiguration->IsActive(); } -SEAnesthesiaMachineConfiguration* SEEquipmentActionCollection::GetAnesthesiaMachineConfiguration() +SEAnesthesiaMachineConfiguration& SEEquipmentActionCollection::GetAnesthesiaMachineConfiguration() { - return m_AnesthesiaMachineConfiguration; + if (m_AnesthesiaMachineConfiguration == nullptr) + m_AnesthesiaMachineConfiguration = new SEAnesthesiaMachineConfiguration(); + return *m_AnesthesiaMachineConfiguration; } const SEAnesthesiaMachineConfiguration* SEEquipmentActionCollection::GetAnesthesiaMachineConfiguration() const { @@ -276,16 +263,19 @@ const SEAnesthesiaMachineConfiguration* SEEquipmentActionCollection::GetAnesthes } void SEEquipmentActionCollection::RemoveAnesthesiaMachineConfiguration() { - SAFE_DELETE(m_AnesthesiaMachineConfiguration); + if (m_AnesthesiaMachineConfiguration) + m_AnesthesiaMachineConfiguration->Deactivate(); } bool SEEquipmentActionCollection::HasAnesthesiaMachineOxygenTankPressureLoss() const { - return m_AnesthesiaMachineOxygenTankPressureLoss == nullptr ? false : true; + return m_AnesthesiaMachineOxygenTankPressureLoss == nullptr ? false : m_AnesthesiaMachineOxygenTankPressureLoss->IsActive(); } -SEAnesthesiaMachineOxygenTankPressureLoss* SEEquipmentActionCollection::GetAnesthesiaMachineOxygenTankPressureLoss() +SEAnesthesiaMachineOxygenTankPressureLoss& SEEquipmentActionCollection::GetAnesthesiaMachineOxygenTankPressureLoss() { - return m_AnesthesiaMachineOxygenTankPressureLoss; + if (m_AnesthesiaMachineOxygenTankPressureLoss == nullptr) + m_AnesthesiaMachineOxygenTankPressureLoss = new SEAnesthesiaMachineOxygenTankPressureLoss(); + return *m_AnesthesiaMachineOxygenTankPressureLoss; } const SEAnesthesiaMachineOxygenTankPressureLoss* SEEquipmentActionCollection::GetAnesthesiaMachineOxygenTankPressureLoss() const { @@ -293,16 +283,19 @@ const SEAnesthesiaMachineOxygenTankPressureLoss* SEEquipmentActionCollection::Ge } void SEEquipmentActionCollection::RemoveAnesthesiaMachineOxygenTankPressureLoss() { - SAFE_DELETE(m_AnesthesiaMachineOxygenTankPressureLoss); + if (m_AnesthesiaMachineOxygenTankPressureLoss) + m_AnesthesiaMachineOxygenTankPressureLoss->Deactivate(); } bool SEEquipmentActionCollection::HasAnesthesiaMachineOxygenWallPortPressureLoss() const { - return m_AnesthesiaMachineOxygenWallPortPressureLoss == nullptr ? false : true; + return m_AnesthesiaMachineOxygenWallPortPressureLoss == nullptr ? false : m_AnesthesiaMachineOxygenWallPortPressureLoss->IsActive(); } -SEAnesthesiaMachineOxygenWallPortPressureLoss* SEEquipmentActionCollection::GetAnesthesiaMachineOxygenWallPortPressureLoss() +SEAnesthesiaMachineOxygenWallPortPressureLoss& SEEquipmentActionCollection::GetAnesthesiaMachineOxygenWallPortPressureLoss() { - return m_AnesthesiaMachineOxygenWallPortPressureLoss; + if (m_AnesthesiaMachineOxygenWallPortPressureLoss == nullptr) + m_AnesthesiaMachineOxygenWallPortPressureLoss = new SEAnesthesiaMachineOxygenWallPortPressureLoss(); + return *m_AnesthesiaMachineOxygenWallPortPressureLoss; } const SEAnesthesiaMachineOxygenWallPortPressureLoss* SEEquipmentActionCollection::GetAnesthesiaMachineOxygenWallPortPressureLoss() const { @@ -310,16 +303,19 @@ const SEAnesthesiaMachineOxygenWallPortPressureLoss* SEEquipmentActionCollection } void SEEquipmentActionCollection::RemoveAnesthesiaMachineOxygenWallPortPressureLoss() { - SAFE_DELETE(m_AnesthesiaMachineOxygenWallPortPressureLoss); + if (m_AnesthesiaMachineOxygenWallPortPressureLoss) + m_AnesthesiaMachineOxygenWallPortPressureLoss->Deactivate(); } bool SEEquipmentActionCollection::HasAnesthesiaMachineExpiratoryValveLeak() const { - return m_AnesthesiaMachineExpiratoryValveLeak == nullptr ? false : true; + return m_AnesthesiaMachineExpiratoryValveLeak == nullptr ? false : m_AnesthesiaMachineExpiratoryValveLeak->IsActive(); } -SEAnesthesiaMachineExpiratoryValveLeak* SEEquipmentActionCollection::GetAnesthesiaMachineExpiratoryValveLeak() +SEAnesthesiaMachineExpiratoryValveLeak& SEEquipmentActionCollection::GetAnesthesiaMachineExpiratoryValveLeak() { - return m_AnesthesiaMachineExpiratoryValveLeak; + if (m_AnesthesiaMachineExpiratoryValveLeak == nullptr) + m_AnesthesiaMachineExpiratoryValveLeak = new SEAnesthesiaMachineExpiratoryValveLeak(); + return *m_AnesthesiaMachineExpiratoryValveLeak; } const SEAnesthesiaMachineExpiratoryValveLeak* SEEquipmentActionCollection::GetAnesthesiaMachineExpiratoryValveLeak() const { @@ -327,16 +323,19 @@ const SEAnesthesiaMachineExpiratoryValveLeak* SEEquipmentActionCollection::GetAn } void SEEquipmentActionCollection::RemoveAnesthesiaMachineExpiratoryValveLeak() { - SAFE_DELETE(m_AnesthesiaMachineExpiratoryValveLeak); + if (m_AnesthesiaMachineExpiratoryValveLeak) + m_AnesthesiaMachineExpiratoryValveLeak->Deactivate(); } bool SEEquipmentActionCollection::HasAnesthesiaMachineExpiratoryValveObstruction() const { - return m_AnesthesiaMachineExpiratoryValveObstruction == nullptr ? false : true; + return m_AnesthesiaMachineExpiratoryValveObstruction == nullptr ? false : m_AnesthesiaMachineExpiratoryValveObstruction->IsActive(); } -SEAnesthesiaMachineExpiratoryValveObstruction* SEEquipmentActionCollection::GetAnesthesiaMachineExpiratoryValveObstruction() +SEAnesthesiaMachineExpiratoryValveObstruction& SEEquipmentActionCollection::GetAnesthesiaMachineExpiratoryValveObstruction() { - return m_AnesthesiaMachineExpiratoryValveObstruction; + if (m_AnesthesiaMachineExpiratoryValveObstruction == nullptr) + m_AnesthesiaMachineExpiratoryValveObstruction = new SEAnesthesiaMachineExpiratoryValveObstruction(); + return *m_AnesthesiaMachineExpiratoryValveObstruction; } const SEAnesthesiaMachineExpiratoryValveObstruction* SEEquipmentActionCollection::GetAnesthesiaMachineExpiratoryValveObstruction() const { @@ -344,16 +343,19 @@ const SEAnesthesiaMachineExpiratoryValveObstruction* SEEquipmentActionCollection } void SEEquipmentActionCollection::RemoveAnesthesiaMachineExpiratoryValveObstruction() { - SAFE_DELETE(m_AnesthesiaMachineExpiratoryValveObstruction); + if (m_AnesthesiaMachineExpiratoryValveObstruction) + m_AnesthesiaMachineExpiratoryValveObstruction->Deactivate(); } bool SEEquipmentActionCollection::HasAnesthesiaMachineInspiratoryValveLeak() const { - return m_AnesthesiaMachineInspiratoryValveLeak == nullptr ? false : true; + return m_AnesthesiaMachineInspiratoryValveLeak == nullptr ? false : m_AnesthesiaMachineInspiratoryValveLeak->IsActive(); } -SEAnesthesiaMachineInspiratoryValveLeak* SEEquipmentActionCollection::GetAnesthesiaMachineInspiratoryValveLeak() +SEAnesthesiaMachineInspiratoryValveLeak& SEEquipmentActionCollection::GetAnesthesiaMachineInspiratoryValveLeak() { - return m_AnesthesiaMachineInspiratoryValveLeak; + if (m_AnesthesiaMachineInspiratoryValveLeak == nullptr) + m_AnesthesiaMachineInspiratoryValveLeak = new SEAnesthesiaMachineInspiratoryValveLeak(); + return *m_AnesthesiaMachineInspiratoryValveLeak; } const SEAnesthesiaMachineInspiratoryValveLeak* SEEquipmentActionCollection::GetAnesthesiaMachineInspiratoryValveLeak() const { @@ -361,16 +363,19 @@ const SEAnesthesiaMachineInspiratoryValveLeak* SEEquipmentActionCollection::GetA } void SEEquipmentActionCollection::RemoveAnesthesiaMachineInspiratoryValveLeak() { - SAFE_DELETE(m_AnesthesiaMachineInspiratoryValveLeak); + if (m_AnesthesiaMachineInspiratoryValveLeak) + m_AnesthesiaMachineInspiratoryValveLeak->Deactivate(); } bool SEEquipmentActionCollection::HasAnesthesiaMachineInspiratoryValveObstruction() const { - return m_AnesthesiaMachineInspiratoryValveObstruction == nullptr ? false : true; + return m_AnesthesiaMachineInspiratoryValveObstruction == nullptr ? false : m_AnesthesiaMachineInspiratoryValveObstruction->IsActive(); } -SEAnesthesiaMachineInspiratoryValveObstruction* SEEquipmentActionCollection::GetAnesthesiaMachineInspiratoryValveObstruction() +SEAnesthesiaMachineInspiratoryValveObstruction& SEEquipmentActionCollection::GetAnesthesiaMachineInspiratoryValveObstruction() { - return m_AnesthesiaMachineInspiratoryValveObstruction; + if (m_AnesthesiaMachineInspiratoryValveObstruction == nullptr) + m_AnesthesiaMachineInspiratoryValveObstruction = new SEAnesthesiaMachineInspiratoryValveObstruction(); + return *m_AnesthesiaMachineInspiratoryValveObstruction; } const SEAnesthesiaMachineInspiratoryValveObstruction* SEEquipmentActionCollection::GetAnesthesiaMachineInspiratoryValveObstruction() const { @@ -378,16 +383,19 @@ const SEAnesthesiaMachineInspiratoryValveObstruction* SEEquipmentActionCollectio } void SEEquipmentActionCollection::RemoveAnesthesiaMachineInspiratoryValveObstruction() { - SAFE_DELETE(m_AnesthesiaMachineInspiratoryValveObstruction); + if (m_AnesthesiaMachineInspiratoryValveObstruction) + m_AnesthesiaMachineInspiratoryValveObstruction->Deactivate(); } bool SEEquipmentActionCollection::HasAnesthesiaMachineMaskLeak() const { - return m_AnesthesiaMachineMaskLeak == nullptr ? false : true; + return m_AnesthesiaMachineMaskLeak == nullptr ? false : m_AnesthesiaMachineMaskLeak->IsActive(); } -SEAnesthesiaMachineMaskLeak* SEEquipmentActionCollection::GetAnesthesiaMachineMaskLeak() +SEAnesthesiaMachineMaskLeak& SEEquipmentActionCollection::GetAnesthesiaMachineMaskLeak() { - return m_AnesthesiaMachineMaskLeak; + if (m_AnesthesiaMachineMaskLeak == nullptr) + m_AnesthesiaMachineMaskLeak = new SEAnesthesiaMachineMaskLeak(); + return *m_AnesthesiaMachineMaskLeak; } const SEAnesthesiaMachineMaskLeak* SEEquipmentActionCollection::GetAnesthesiaMachineMaskLeak() const { @@ -395,16 +403,19 @@ const SEAnesthesiaMachineMaskLeak* SEEquipmentActionCollection::GetAnesthesiaMac } void SEEquipmentActionCollection::RemoveAnesthesiaMachineMaskLeak() { - SAFE_DELETE(m_AnesthesiaMachineMaskLeak); + if (m_AnesthesiaMachineMaskLeak) + m_AnesthesiaMachineMaskLeak->Deactivate(); } bool SEEquipmentActionCollection::HasAnesthesiaMachineSodaLimeFailure() const { - return m_AnesthesiaMachineSodaLimeFailure == nullptr ? false : true; + return m_AnesthesiaMachineSodaLimeFailure == nullptr ? false : m_AnesthesiaMachineSodaLimeFailure->IsActive(); } -SEAnesthesiaMachineSodaLimeFailure* SEEquipmentActionCollection::GetAnesthesiaMachineSodaLimeFailure() +SEAnesthesiaMachineSodaLimeFailure& SEEquipmentActionCollection::GetAnesthesiaMachineSodaLimeFailure() { - return m_AnesthesiaMachineSodaLimeFailure; + if (m_AnesthesiaMachineSodaLimeFailure == nullptr) + m_AnesthesiaMachineSodaLimeFailure = new SEAnesthesiaMachineSodaLimeFailure(); + return *m_AnesthesiaMachineSodaLimeFailure; } const SEAnesthesiaMachineSodaLimeFailure* SEEquipmentActionCollection::GetAnesthesiaMachineSodaLimeFailure() const { @@ -412,16 +423,19 @@ const SEAnesthesiaMachineSodaLimeFailure* SEEquipmentActionCollection::GetAnesth } void SEEquipmentActionCollection::RemoveAnesthesiaMachineSodaLimeFailure() { - SAFE_DELETE(m_AnesthesiaMachineSodaLimeFailure); + if (m_AnesthesiaMachineSodaLimeFailure) + m_AnesthesiaMachineSodaLimeFailure->Deactivate(); } bool SEEquipmentActionCollection::HasAnesthesiaMachineTubeCuffLeak() const { - return m_AnesthesiaMachineTubeCuffLeak == nullptr ? false : true; + return m_AnesthesiaMachineTubeCuffLeak == nullptr ? false : m_AnesthesiaMachineTubeCuffLeak->IsActive(); } -SEAnesthesiaMachineTubeCuffLeak* SEEquipmentActionCollection::GetAnesthesiaMachineTubeCuffLeak() +SEAnesthesiaMachineTubeCuffLeak& SEEquipmentActionCollection::GetAnesthesiaMachineTubeCuffLeak() { - return m_AnesthesiaMachineTubeCuffLeak; + if (m_AnesthesiaMachineTubeCuffLeak == nullptr) + m_AnesthesiaMachineTubeCuffLeak = new SEAnesthesiaMachineTubeCuffLeak(); + return *m_AnesthesiaMachineTubeCuffLeak; } const SEAnesthesiaMachineTubeCuffLeak* SEEquipmentActionCollection::GetAnesthesiaMachineTubeCuffLeak() const { @@ -429,16 +443,19 @@ const SEAnesthesiaMachineTubeCuffLeak* SEEquipmentActionCollection::GetAnesthesi } void SEEquipmentActionCollection::RemoveAnesthesiaMachineTubeCuffLeak() { - SAFE_DELETE(m_AnesthesiaMachineTubeCuffLeak); + if (m_AnesthesiaMachineTubeCuffLeak) + m_AnesthesiaMachineTubeCuffLeak->Deactivate(); } bool SEEquipmentActionCollection::HasAnesthesiaMachineVaporizerFailure() const { - return m_AnesthesiaMachineVaporizerFailure == nullptr ? false : true; + return m_AnesthesiaMachineVaporizerFailure == nullptr ? false : m_AnesthesiaMachineVaporizerFailure->IsActive(); } -SEAnesthesiaMachineVaporizerFailure* SEEquipmentActionCollection::GetAnesthesiaMachineVaporizerFailure() +SEAnesthesiaMachineVaporizerFailure& SEEquipmentActionCollection::GetAnesthesiaMachineVaporizerFailure() { - return m_AnesthesiaMachineVaporizerFailure; + if (m_AnesthesiaMachineVaporizerFailure == nullptr) + m_AnesthesiaMachineVaporizerFailure = new SEAnesthesiaMachineVaporizerFailure(); + return *m_AnesthesiaMachineVaporizerFailure; } const SEAnesthesiaMachineVaporizerFailure* SEEquipmentActionCollection::GetAnesthesiaMachineVaporizerFailure() const { @@ -446,16 +463,19 @@ const SEAnesthesiaMachineVaporizerFailure* SEEquipmentActionCollection::GetAnest } void SEEquipmentActionCollection::RemoveAnesthesiaMachineVaporizerFailure() { - SAFE_DELETE(m_AnesthesiaMachineVaporizerFailure); + if (m_AnesthesiaMachineVaporizerFailure) + m_AnesthesiaMachineVaporizerFailure->Deactivate(); } bool SEEquipmentActionCollection::HasAnesthesiaMachineVentilatorPressureLoss() const { - return m_AnesthesiaMachineVentilatorPressureLoss == nullptr ? false : true; + return m_AnesthesiaMachineVentilatorPressureLoss == nullptr ? false : m_AnesthesiaMachineVentilatorPressureLoss->IsActive(); } -SEAnesthesiaMachineVentilatorPressureLoss* SEEquipmentActionCollection::GetAnesthesiaMachineVentilatorPressureLoss() +SEAnesthesiaMachineVentilatorPressureLoss& SEEquipmentActionCollection::GetAnesthesiaMachineVentilatorPressureLoss() { - return m_AnesthesiaMachineVentilatorPressureLoss; + if (m_AnesthesiaMachineVentilatorPressureLoss == nullptr) + m_AnesthesiaMachineVentilatorPressureLoss = new SEAnesthesiaMachineVentilatorPressureLoss(); + return *m_AnesthesiaMachineVentilatorPressureLoss; } const SEAnesthesiaMachineVentilatorPressureLoss* SEEquipmentActionCollection::GetAnesthesiaMachineVentilatorPressureLoss() const { @@ -463,16 +483,19 @@ const SEAnesthesiaMachineVentilatorPressureLoss* SEEquipmentActionCollection::Ge } void SEEquipmentActionCollection::RemoveAnesthesiaMachineVentilatorPressureLoss() { - SAFE_DELETE(m_AnesthesiaMachineVentilatorPressureLoss); + if (m_AnesthesiaMachineVentilatorPressureLoss) + m_AnesthesiaMachineVentilatorPressureLoss->Deactivate(); } bool SEEquipmentActionCollection::HasAnesthesiaMachineYPieceDisconnect() const { - return m_AnesthesiaMachineYPieceDisconnect == nullptr ? false : true; + return m_AnesthesiaMachineYPieceDisconnect == nullptr ? false : m_AnesthesiaMachineYPieceDisconnect->IsActive(); } -SEAnesthesiaMachineYPieceDisconnect* SEEquipmentActionCollection::GetAnesthesiaMachineYPieceDisconnect() +SEAnesthesiaMachineYPieceDisconnect& SEEquipmentActionCollection::GetAnesthesiaMachineYPieceDisconnect() { - return m_AnesthesiaMachineYPieceDisconnect; + if (m_AnesthesiaMachineYPieceDisconnect == nullptr) + m_AnesthesiaMachineYPieceDisconnect = new SEAnesthesiaMachineYPieceDisconnect(); + return *m_AnesthesiaMachineYPieceDisconnect; } const SEAnesthesiaMachineYPieceDisconnect* SEEquipmentActionCollection::GetAnesthesiaMachineYPieceDisconnect() const { @@ -480,16 +503,19 @@ const SEAnesthesiaMachineYPieceDisconnect* SEEquipmentActionCollection::GetAnest } void SEEquipmentActionCollection::RemoveAnesthesiaMachineYPieceDisconnect() { - SAFE_DELETE(m_AnesthesiaMachineYPieceDisconnect); + if (m_AnesthesiaMachineYPieceDisconnect) + m_AnesthesiaMachineYPieceDisconnect->Deactivate(); } bool SEEquipmentActionCollection::HasInhalerConfiguration() const { - return m_InhalerConfiguration == nullptr ? false : true; + return m_InhalerConfiguration == nullptr ? false : m_InhalerConfiguration->IsActive(); } -SEInhalerConfiguration* SEEquipmentActionCollection::GetInhalerConfiguration() +SEInhalerConfiguration& SEEquipmentActionCollection::GetInhalerConfiguration() { - return m_InhalerConfiguration; + if (m_InhalerConfiguration == nullptr) + m_InhalerConfiguration = new SEInhalerConfiguration(); + return *m_InhalerConfiguration; } const SEInhalerConfiguration* SEEquipmentActionCollection::GetInhalerConfiguration() const { @@ -497,16 +523,19 @@ const SEInhalerConfiguration* SEEquipmentActionCollection::GetInhalerConfigurati } void SEEquipmentActionCollection::RemoveInhalerConfiguration() { - SAFE_DELETE(m_InhalerConfiguration); + if (m_InhalerConfiguration) + m_InhalerConfiguration->Deactivate(); } bool SEEquipmentActionCollection::HasMechanicalVentilatorConfiguration() const { - return m_MechanicalVentilatorConfiguration == nullptr ? false : true; + return m_MechanicalVentilatorConfiguration == nullptr ? false : m_MechanicalVentilatorConfiguration->IsActive(); } -SEMechanicalVentilatorConfiguration* SEEquipmentActionCollection::GetMechanicalVentilatorConfiguration() +SEMechanicalVentilatorConfiguration& SEEquipmentActionCollection::GetMechanicalVentilatorConfiguration() { - return m_MechanicalVentilatorConfiguration; + if (m_MechanicalVentilatorConfiguration == nullptr) + m_MechanicalVentilatorConfiguration = new SEMechanicalVentilatorConfiguration(); + return *m_MechanicalVentilatorConfiguration; } const SEMechanicalVentilatorConfiguration* SEEquipmentActionCollection::GetMechanicalVentilatorConfiguration() const { @@ -514,7 +543,8 @@ const SEMechanicalVentilatorConfiguration* SEEquipmentActionCollection::GetMecha } void SEEquipmentActionCollection::RemoveMechanicalVentilatorConfiguration() { - SAFE_DELETE(m_MechanicalVentilatorConfiguration); + if (m_MechanicalVentilatorConfiguration) + m_MechanicalVentilatorConfiguration->Deactivate(); } void SEEquipmentActionCollection::GetAllActions(std::vector& actions) const @@ -551,4 +581,42 @@ void SEEquipmentActionCollection::GetAllActions(std::vector& ac if(HasMechanicalVentilatorConfiguration()) actions.push_back(GetMechanicalVentilatorConfiguration()); -} \ No newline at end of file +} + +const SEScalar* SEEquipmentActionCollection::GetScalar(const std::string& actionName, const std::string& cmptName, const std::string& substance, const std::string& property) +{ + if (actionName == "AnesthesiaMachineConfiguration") + return GetAnesthesiaMachineConfiguration().GetScalar(property); + if (actionName == "AnesthesiaMachineOxygenTankPressureLoss") + return GetAnesthesiaMachineOxygenTankPressureLoss().GetScalar(property); + if (actionName == "AnesthesiaMachineOxygenWallPortPressureLoss") + return GetAnesthesiaMachineOxygenWallPortPressureLoss().GetScalar(property); + if (actionName == "AnesthesiaMachineExpiratoryValveLeak") + return GetAnesthesiaMachineExpiratoryValveLeak().GetScalar(property); + if (actionName == "AnesthesiaMachineExpiratoryValveObstruction") + return GetAnesthesiaMachineExpiratoryValveObstruction().GetScalar(property); + if (actionName == "AnesthesiaMachineInspiratoryValveLeak") + return GetAnesthesiaMachineInspiratoryValveLeak().GetScalar(property); + if (actionName == "AnesthesiaMachineInspiratoryValveObstruction") + return GetAnesthesiaMachineInspiratoryValveObstruction().GetScalar(property); + if (actionName == "AnesthesiaMachineMaskLeak") + return GetAnesthesiaMachineMaskLeak().GetScalar(property); + if (actionName == "AnesthesiaMachineSodaLimeFailure") + return GetAnesthesiaMachineSodaLimeFailure().GetScalar(property); + if (actionName == "AnesthesiaMachineTubeCuffLeak") + return GetAnesthesiaMachineTubeCuffLeak().GetScalar(property); + if (actionName == "AnesthesiaMachineVaporizerFailure") + return GetAnesthesiaMachineVaporizerFailure().GetScalar(property); + if (actionName == "AnesthesiaMachineVentilatorPressureLoss") + return GetAnesthesiaMachineVentilatorPressureLoss().GetScalar(property); + if (actionName == "AnesthesiaMachineYPieceDisconnect") + return GetAnesthesiaMachineYPieceDisconnect().GetScalar(property); + + if (actionName == "InhalerConfiguration") + return GetInhalerConfiguration().GetScalar(property); + + if (actionName == "MechanicalVentilatorConfiguration") + return GetMechanicalVentilatorConfiguration().GetScalar(property); + + return nullptr; +} diff --git a/src/cpp/cdm/engine/SEEquipmentActionCollection.h b/src/cpp/cdm/engine/SEEquipmentActionCollection.h index 642386632c8da2827f3194103c0c64d192875011..3944d4b86ef4ea523c8d8135134d7292690861c0 100644 --- a/src/cpp/cdm/engine/SEEquipmentActionCollection.h +++ b/src/cpp/cdm/engine/SEEquipmentActionCollection.h @@ -34,95 +34,98 @@ class CDM_DECL SEEquipmentActionCollection : public Loggable friend class PBEngine;//friend the serialization class friend class SEActionManager; protected: - SEEquipmentActionCollection(Logger* logger=nullptr); + SEEquipmentActionCollection(SESubstanceManager& subMgr); public: ~SEEquipmentActionCollection(); // STATE ACTION bool HasAnesthesiaMachineConfiguration() const; - SEAnesthesiaMachineConfiguration* GetAnesthesiaMachineConfiguration(); + SEAnesthesiaMachineConfiguration& GetAnesthesiaMachineConfiguration(); const SEAnesthesiaMachineConfiguration* GetAnesthesiaMachineConfiguration() const; void RemoveAnesthesiaMachineConfiguration(); bool HasInhalerConfiguration() const; - SEInhalerConfiguration* GetInhalerConfiguration(); + SEInhalerConfiguration& GetInhalerConfiguration(); const SEInhalerConfiguration* GetInhalerConfiguration() const; void RemoveInhalerConfiguration(); bool HasMechanicalVentilatorConfiguration() const; - SEMechanicalVentilatorConfiguration* GetMechanicalVentilatorConfiguration(); + SEMechanicalVentilatorConfiguration& GetMechanicalVentilatorConfiguration(); const SEMechanicalVentilatorConfiguration* GetMechanicalVentilatorConfiguration() const; void RemoveMechanicalVentilatorConfiguration(); // INCIDENT ACTIONS bool HasAnesthesiaMachineOxygenTankPressureLoss() const; - SEAnesthesiaMachineOxygenTankPressureLoss* GetAnesthesiaMachineOxygenTankPressureLoss(); + SEAnesthesiaMachineOxygenTankPressureLoss& GetAnesthesiaMachineOxygenTankPressureLoss(); const SEAnesthesiaMachineOxygenTankPressureLoss* GetAnesthesiaMachineOxygenTankPressureLoss() const; void RemoveAnesthesiaMachineOxygenTankPressureLoss(); bool HasAnesthesiaMachineOxygenWallPortPressureLoss() const; - SEAnesthesiaMachineOxygenWallPortPressureLoss* GetAnesthesiaMachineOxygenWallPortPressureLoss(); + SEAnesthesiaMachineOxygenWallPortPressureLoss& GetAnesthesiaMachineOxygenWallPortPressureLoss(); const SEAnesthesiaMachineOxygenWallPortPressureLoss* GetAnesthesiaMachineOxygenWallPortPressureLoss() const; void RemoveAnesthesiaMachineOxygenWallPortPressureLoss(); // FAILURE ACTIONS bool HasAnesthesiaMachineExpiratoryValveLeak() const; - SEAnesthesiaMachineExpiratoryValveLeak* GetAnesthesiaMachineExpiratoryValveLeak(); + SEAnesthesiaMachineExpiratoryValveLeak& GetAnesthesiaMachineExpiratoryValveLeak(); const SEAnesthesiaMachineExpiratoryValveLeak* GetAnesthesiaMachineExpiratoryValveLeak() const; void RemoveAnesthesiaMachineExpiratoryValveLeak(); bool HasAnesthesiaMachineExpiratoryValveObstruction() const; - SEAnesthesiaMachineExpiratoryValveObstruction* GetAnesthesiaMachineExpiratoryValveObstruction(); + SEAnesthesiaMachineExpiratoryValveObstruction& GetAnesthesiaMachineExpiratoryValveObstruction(); const SEAnesthesiaMachineExpiratoryValveObstruction* GetAnesthesiaMachineExpiratoryValveObstruction() const; void RemoveAnesthesiaMachineExpiratoryValveObstruction(); bool HasAnesthesiaMachineInspiratoryValveLeak() const; - SEAnesthesiaMachineInspiratoryValveLeak* GetAnesthesiaMachineInspiratoryValveLeak(); + SEAnesthesiaMachineInspiratoryValveLeak& GetAnesthesiaMachineInspiratoryValveLeak(); const SEAnesthesiaMachineInspiratoryValveLeak* GetAnesthesiaMachineInspiratoryValveLeak() const; void RemoveAnesthesiaMachineInspiratoryValveLeak(); bool HasAnesthesiaMachineInspiratoryValveObstruction() const; - SEAnesthesiaMachineInspiratoryValveObstruction* GetAnesthesiaMachineInspiratoryValveObstruction(); + SEAnesthesiaMachineInspiratoryValveObstruction& GetAnesthesiaMachineInspiratoryValveObstruction(); const SEAnesthesiaMachineInspiratoryValveObstruction* GetAnesthesiaMachineInspiratoryValveObstruction() const; void RemoveAnesthesiaMachineInspiratoryValveObstruction(); bool HasAnesthesiaMachineMaskLeak() const; - SEAnesthesiaMachineMaskLeak* GetAnesthesiaMachineMaskLeak(); + SEAnesthesiaMachineMaskLeak& GetAnesthesiaMachineMaskLeak(); const SEAnesthesiaMachineMaskLeak* GetAnesthesiaMachineMaskLeak() const; void RemoveAnesthesiaMachineMaskLeak(); bool HasAnesthesiaMachineSodaLimeFailure() const; - SEAnesthesiaMachineSodaLimeFailure* GetAnesthesiaMachineSodaLimeFailure(); + SEAnesthesiaMachineSodaLimeFailure& GetAnesthesiaMachineSodaLimeFailure(); const SEAnesthesiaMachineSodaLimeFailure* GetAnesthesiaMachineSodaLimeFailure() const; void RemoveAnesthesiaMachineSodaLimeFailure(); bool HasAnesthesiaMachineTubeCuffLeak() const; - SEAnesthesiaMachineTubeCuffLeak* GetAnesthesiaMachineTubeCuffLeak(); + SEAnesthesiaMachineTubeCuffLeak& GetAnesthesiaMachineTubeCuffLeak(); const SEAnesthesiaMachineTubeCuffLeak* GetAnesthesiaMachineTubeCuffLeak() const; void RemoveAnesthesiaMachineTubeCuffLeak(); bool HasAnesthesiaMachineVaporizerFailure() const; - SEAnesthesiaMachineVaporizerFailure* GetAnesthesiaMachineVaporizerFailure(); + SEAnesthesiaMachineVaporizerFailure& GetAnesthesiaMachineVaporizerFailure(); const SEAnesthesiaMachineVaporizerFailure* GetAnesthesiaMachineVaporizerFailure() const; void RemoveAnesthesiaMachineVaporizerFailure(); bool HasAnesthesiaMachineVentilatorPressureLoss() const; - SEAnesthesiaMachineVentilatorPressureLoss* GetAnesthesiaMachineVentilatorPressureLoss(); + SEAnesthesiaMachineVentilatorPressureLoss& GetAnesthesiaMachineVentilatorPressureLoss(); const SEAnesthesiaMachineVentilatorPressureLoss* GetAnesthesiaMachineVentilatorPressureLoss() const; void RemoveAnesthesiaMachineVentilatorPressureLoss(); bool HasAnesthesiaMachineYPieceDisconnect() const; - SEAnesthesiaMachineYPieceDisconnect* GetAnesthesiaMachineYPieceDisconnect(); + SEAnesthesiaMachineYPieceDisconnect& GetAnesthesiaMachineYPieceDisconnect(); const SEAnesthesiaMachineYPieceDisconnect* GetAnesthesiaMachineYPieceDisconnect() const; void RemoveAnesthesiaMachineYPieceDisconnect(); void GetAllActions(std::vector& v) const; + const SEScalar* GetScalar(const std::string& actionName, const std::string& cmptName, const std::string& substance, const std::string& property); protected: void Clear(); - bool ProcessAction(const SEEquipmentAction& action, SESubstanceManager&); + bool ProcessAction(const SEEquipmentAction& action); + + SESubstanceManager& m_SubMgr; SEAnesthesiaMachineConfiguration* m_AnesthesiaMachineConfiguration; //Anesthesia Machine Incidents diff --git a/src/cpp/cdm/engine/SEOverrides.cpp b/src/cpp/cdm/engine/SEOverrides.cpp index 1bb29e5910ed386c25c49bd8224f57728efe749e..826f4dc20a3577fbd92bb26e65eb4f274d660eb7 100644 --- a/src/cpp/cdm/engine/SEOverrides.cpp +++ b/src/cpp/cdm/engine/SEOverrides.cpp @@ -31,19 +31,6 @@ bool SEOverrides::IsValid() const return HasProperty(); } -void SEOverrides::ToString(std::ostream &str) const -{ - if(HasComment()) - str<<"\n\tComment : "<1; @@ -72,3 +59,22 @@ void SEOverrides::RemoveProperties() { m_ScalarProperties.clear(); } + +void SEOverrides::ToString(std::ostream& str) const +{ + if (HasComment()) + str << "\n\tComment : " << m_Comment; + for (auto itr : m_ScalarProperties) + { + if (itr.unit.empty()) + str << "\n\tOverride " << itr.name << " with " << itr.value; + else + str << "\n\tOverride " << itr.name << " with " << itr.value << "(" << itr.unit << ")"; + } +} + +const SEScalar* SEOverrides::GetScalar(const std::string& name) +{ + // Probably want to iterate over the properties and look for the name? + return nullptr; +} diff --git a/src/cpp/cdm/engine/SEOverrides.h b/src/cpp/cdm/engine/SEOverrides.h index 1313d009b123de30a5de31687e720e94d9ecb085..83ac0d81297d551d66c190359e55db79a3cf3c10 100644 --- a/src/cpp/cdm/engine/SEOverrides.h +++ b/src/cpp/cdm/engine/SEOverrides.h @@ -18,8 +18,6 @@ public: virtual bool IsValid() const; - virtual void ToString(std::ostream &str) const; - virtual bool HasProperty() const; virtual void AddScalarProperty(const std::string& name, double value); virtual void AddScalarProperty(const std::string& name, double value, std::string unit); @@ -28,6 +26,10 @@ public: virtual const std::vector& GetScalarProperties() const; virtual void RemoveProperties(); + virtual void ToString(std::ostream &str) const; + + virtual const SEScalar* GetScalar(const std::string& name); + protected: std::vector m_ScalarProperties; }; \ No newline at end of file diff --git a/src/cpp/cdm/engine/SEPatientActionCollection.cpp b/src/cpp/cdm/engine/SEPatientActionCollection.cpp index cced3ae99d48fa3704c7c9f0343f6f2878132829..4014e98383c44d6ad5869e0ae6d78a2148b58190 100644 --- a/src/cpp/cdm/engine/SEPatientActionCollection.cpp +++ b/src/cpp/cdm/engine/SEPatientActionCollection.cpp @@ -43,7 +43,7 @@ #include "properties/SEScalarVolumePerTime.h" -SEPatientActionCollection::SEPatientActionCollection(Logger* logger) : Loggable(logger) +SEPatientActionCollection::SEPatientActionCollection(SESubstanceManager& subMgr) : m_SubMgr(subMgr), Loggable(subMgr.GetLogger()) { m_ARDSExacerbation = nullptr; m_AcuteStress = nullptr; @@ -52,7 +52,8 @@ SEPatientActionCollection::SEPatientActionCollection(Logger* logger) : Loggable( m_BrainInjury = nullptr; m_Bronchoconstriction = nullptr; m_CardiacArrest = nullptr; - m_ChestCompression = nullptr; + m_ChestCompressionForce = nullptr; + m_ChestCompressionForceScale = nullptr; m_ConsciousRespiration = nullptr; m_ConsumeNutrients = nullptr; m_COPDExacerbation = nullptr; @@ -79,7 +80,42 @@ SEPatientActionCollection::SEPatientActionCollection(Logger* logger) : Loggable( SEPatientActionCollection::~SEPatientActionCollection() { - Clear(); + SAFE_DELETE(m_ARDSExacerbation); + SAFE_DELETE(m_AcuteStress); + SAFE_DELETE(m_AirwayObstruction); + SAFE_DELETE(m_AsthmaAttack); + SAFE_DELETE(m_BrainInjury); + SAFE_DELETE(m_Bronchoconstriction); + SAFE_DELETE(m_CardiacArrest); + SAFE_DELETE(m_ChestCompressionForce); + SAFE_DELETE(m_ChestCompressionForceScale); + SAFE_DELETE(m_LeftChestOcclusiveDressing); + SAFE_DELETE(m_RightChestOcclusiveDressing); + SAFE_DELETE(m_ConsciousRespiration); + SAFE_DELETE(m_ConsumeNutrients); + SAFE_DELETE(m_COPDExacerbation); + SAFE_DELETE(m_Dyspnea); + SAFE_DELETE(m_Exercise); + SAFE_DELETE(m_Intubation); + SAFE_DELETE(m_ImpairedAlveolarExchangeExacerbation); + SAFE_DELETE(m_LobarPneumoniaExacerbation); + SAFE_DELETE(m_MechanicalVentilation); + SAFE_DELETE(m_LeftNeedleDecompression); + SAFE_DELETE(m_RightNeedleDecompression); + SAFE_DELETE(m_PericardialEffusion); + SAFE_DELETE(m_PulmonaryShuntExacerbation); + SAFE_DELETE(m_RespiratoryFatigue); + SAFE_DELETE(m_SupplementalOxygen); + SAFE_DELETE(m_LeftClosedTensionPneumothorax); + SAFE_DELETE(m_LeftOpenTensionPneumothorax); + SAFE_DELETE(m_RightClosedTensionPneumothorax); + SAFE_DELETE(m_RightOpenTensionPneumothorax); + SAFE_DELETE(m_Urinate); + + DELETE_VECTOR(m_Hemorrhages); + DELETE_VECTOR(m_SubstanceBoluses); + DELETE_VECTOR(m_SubstanceInfusions); + DELETE_VECTOR(m_SubstanceCompoundInfusions); } void SEPatientActionCollection::Clear() @@ -90,7 +126,8 @@ void SEPatientActionCollection::Clear() RemoveAsthmaAttack(); RemoveBrainInjury(); RemoveBronchoconstriction(); - RemoveChestCompression(); + RemoveChestCompressionForce(); + RemoveChestCompressionForceScale(); RemoveCardiacArrest(); RemoveChronicObstructivePulmonaryDiseaseExacerbation(); RemoveConsciousRespiration(); @@ -114,13 +151,17 @@ void SEPatientActionCollection::Clear() RemoveRightClosedTensionPneumothorax(); RemoveUrinate(); - DELETE_MAP_SECOND(m_Hemorrhages); - DELETE_MAP_SECOND(m_SubstanceBolus); - DELETE_MAP_SECOND(m_SubstanceInfusions); - DELETE_MAP_SECOND(m_SubstanceCompoundInfusions); + for (auto a : m_Hemorrhages) + a->Deactivate(); + for (auto a : m_SubstanceBoluses) + a->Deactivate(); + for (auto a : m_SubstanceInfusions) + a->Deactivate(); + for (auto a : m_SubstanceCompoundInfusions) + a->Deactivate(); } -bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SESubstanceManager& subMgr) +bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action) { const SEPatientAssessmentRequest* patientAss = dynamic_cast(&action); if (patientAss != nullptr) @@ -147,9 +188,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEAcuteRespiratoryDistressSyndromeExacerbation* ards = dynamic_cast(&action); if (ards != nullptr) { - if (m_ARDSExacerbation == nullptr) - m_ARDSExacerbation = new SEAcuteRespiratoryDistressSyndromeExacerbation(); - m_ARDSExacerbation->Copy(*ards); + GetAcuteRespiratoryDistressSyndromeExacerbation().Copy(*ards, true); + m_ARDSExacerbation->Activate(); if (!m_ARDSExacerbation->IsActive()) RemoveAcuteRespiratoryDistressSyndromeExacerbation(); return true; @@ -158,9 +198,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEAcuteStress* aStress = dynamic_cast(&action); if (aStress != nullptr) { - if (m_AcuteStress == nullptr) - m_AcuteStress = new SEAcuteStress(); - m_AcuteStress->Copy(*aStress); + GetAcuteStress().Copy(*aStress, true); + m_AcuteStress->Activate(); if (!m_AcuteStress->IsActive()) RemoveAcuteStress(); return true; @@ -169,9 +208,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEAirwayObstruction* airwayObst = dynamic_cast(&action); if (airwayObst != nullptr) { - if (m_AirwayObstruction == nullptr) - m_AirwayObstruction = new SEAirwayObstruction(); - m_AirwayObstruction->Copy(*airwayObst); + GetAirwayObstruction().Copy(*airwayObst, true); + m_AirwayObstruction->Activate(); if (!m_AirwayObstruction->IsActive()) RemoveAirwayObstruction(); return true; @@ -180,9 +218,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEAsthmaAttack* asthmaattack = dynamic_cast(&action); if (asthmaattack != nullptr) { - if (m_AsthmaAttack == nullptr) - m_AsthmaAttack = new SEAsthmaAttack(); - m_AsthmaAttack->Copy(*asthmaattack); + GetAsthmaAttack().Copy(*asthmaattack, true); + m_AsthmaAttack->Activate(); if (!m_AsthmaAttack->IsActive()) RemoveAsthmaAttack(); return true; @@ -191,9 +228,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEBrainInjury* brainInjury = dynamic_cast(&action); if (brainInjury != nullptr) { - if (m_BrainInjury == nullptr) - m_BrainInjury = new SEBrainInjury(); - m_BrainInjury->Copy(*brainInjury); + GetBrainInjury().Copy(*brainInjury, true); + m_BrainInjury->Activate(); if (!m_BrainInjury->IsActive()) RemoveBrainInjury(); return true; @@ -202,9 +238,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEBronchoconstriction* bronchoconstr = dynamic_cast(&action); if (bronchoconstr != nullptr) { - if (m_Bronchoconstriction == nullptr) - m_Bronchoconstriction = new SEBronchoconstriction(); - m_Bronchoconstriction->Copy(*bronchoconstr); + GetBronchoconstriction().Copy(*bronchoconstr, true); + m_Bronchoconstriction->Activate(); if (!m_Bronchoconstriction->IsActive()) RemoveBronchoconstriction(); return true; @@ -213,44 +248,34 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SECardiacArrest* cardiacarrest = dynamic_cast(&action); if (cardiacarrest != nullptr) { - if (m_CardiacArrest == nullptr) - m_CardiacArrest = new SECardiacArrest(); - m_CardiacArrest->Copy(*cardiacarrest); + GetCardiacArrest().Copy(*cardiacarrest, true); + m_CardiacArrest->Activate(); if (!m_CardiacArrest->IsActive()) RemoveCardiacArrest(); return true; } - const SEChestCompression* chestcomp = dynamic_cast(&action); - if (chestcomp != nullptr) + const SEChestCompressionForce* cprForce = dynamic_cast(&action); + if (cprForce != nullptr) { - const SEChestCompressionForce* cprForce = dynamic_cast(chestcomp); - if (cprForce != nullptr) - { - if (HasChestCompressionForceScale()) - RemoveChestCompression(); - if (m_ChestCompression == nullptr) - m_ChestCompression = new SEChestCompressionForce(); - ((SEChestCompressionForce*)m_ChestCompression)->Copy(*cprForce); - if (!m_ChestCompression->IsActive()) - RemoveChestCompression(); - return true; - } - const SEChestCompressionForceScale* cprScale = dynamic_cast(chestcomp); - if (cprScale != nullptr) - { - if (HasChestCompressionForce()) - RemoveChestCompression(); - if (m_ChestCompression == nullptr) - m_ChestCompression = new SEChestCompressionForceScale(); - ((SEChestCompressionForceScale*)m_ChestCompression)->Copy(*cprScale); - if (!m_ChestCompression->IsActive()) - RemoveChestCompression(); - return true; - } - Error("Unknown Chest Compression Type"); - /// \error Unknown ChestCompression type - return false; + if (HasChestCompressionForceScale()) + RemoveChestCompressionForceScale(); + GetChestCompressionForce().Copy(*cprForce, true); + m_ChestCompressionForce->Activate(); + if (!m_ChestCompressionForce->IsActive()) + RemoveChestCompressionForce(); + return true; + } + const SEChestCompressionForceScale* cprScale = dynamic_cast(&action); + if (cprScale != nullptr) + { + if (HasChestCompressionForce()) + RemoveChestCompressionForce(); + GetChestCompressionForceScale().Copy(*cprScale, true); + m_ChestCompressionForceScale->Activate(); + if (!m_ChestCompressionForceScale->IsActive()) + RemoveChestCompressionForceScale(); + return true; } const SEChestOcclusiveDressing* chestOccl = dynamic_cast(&action); @@ -258,18 +283,16 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES { if (chestOccl->GetSide() == eSide::Left) { - if (m_LeftChestOcclusiveDressing == nullptr) - m_LeftChestOcclusiveDressing = new SEChestOcclusiveDressing(); - m_LeftChestOcclusiveDressing->Copy(*chestOccl); + GetLeftChestOcclusiveDressing().Copy(*chestOccl, true); + m_LeftChestOcclusiveDressing->Activate(); if (!m_LeftChestOcclusiveDressing->IsActive()) RemoveLeftChestOcclusiveDressing(); return true; } else if (chestOccl->GetSide() == eSide::Right) { - if (m_RightChestOcclusiveDressing == nullptr) - m_RightChestOcclusiveDressing = new SEChestOcclusiveDressing(); - m_RightChestOcclusiveDressing->Copy(*chestOccl); + GetRightChestOcclusiveDressing().Copy(*chestOccl, true); + m_RightChestOcclusiveDressing->Activate(); if (!m_RightChestOcclusiveDressing->IsActive()) RemoveRightChestOcclusiveDressing(); return true; @@ -279,9 +302,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEChronicObstructivePulmonaryDiseaseExacerbation* copd = dynamic_cast(&action); if (copd != nullptr) { - if (m_COPDExacerbation == nullptr) - m_COPDExacerbation = new SEChronicObstructivePulmonaryDiseaseExacerbation(); - m_COPDExacerbation->Copy(*copd); + GetChronicObstructivePulmonaryDiseaseExacerbation().Copy(*copd, true); + m_COPDExacerbation->Activate(); if (!m_COPDExacerbation->IsActive()) RemoveChronicObstructivePulmonaryDiseaseExacerbation(); return true; @@ -290,14 +312,13 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEConsciousRespiration* conResp = dynamic_cast(&action); if (conResp != nullptr) { - if (m_ConsciousRespiration == nullptr) - m_ConsciousRespiration = new SEConsciousRespiration(); - if (m_ConsciousRespiration->HasCommands()) + if (m_ConsciousRespiration != nullptr && m_ConsciousRespiration->HasCommands()) { Warning("Processing conscious respiration before the previous conscious breath was completed."); Warning("Previous conscious respiration commands will not be processed."); } - m_ConsciousRespiration->Copy(*conResp); + GetConsciousRespiration().Copy(*conResp, true); + m_ConsciousRespiration->Activate(); if (!m_ConsciousRespiration->IsActive()) RemoveConsciousRespiration(); return true; @@ -306,9 +327,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEConsumeNutrients* consume = dynamic_cast(&action); if (consume != nullptr) { - if (m_ConsumeNutrients == nullptr) - m_ConsumeNutrients = new SEConsumeNutrients(); - m_ConsumeNutrients->Copy(*consume); + GetConsumeNutrients().Copy(*consume, true); + m_ConsumeNutrients->Activate(); if (!m_ConsumeNutrients->IsActive()) RemoveConsumeNutrients(); return true; @@ -317,9 +337,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEDyspnea* Dyspnea = dynamic_cast(&action); if (Dyspnea != nullptr) { - if (m_Dyspnea == nullptr) - m_Dyspnea = new SEDyspnea(); - m_Dyspnea->Copy(*Dyspnea); + GetDyspnea().Copy(*Dyspnea, true); + m_Dyspnea->Activate(); if (!m_Dyspnea->IsActive()) RemoveDyspnea(); return true; @@ -328,9 +347,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEExercise* exercise = dynamic_cast(&action); if (exercise != nullptr) { - if (m_Exercise == nullptr) - m_Exercise = new SEExercise(); - m_Exercise->Copy(*exercise); + GetExercise().Copy(*exercise, true); + m_Exercise->Activate(); if (!m_Exercise->IsActive()) RemoveExercise(); return true; @@ -339,14 +357,10 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEHemorrhage* hem = dynamic_cast(&action); if (hem != nullptr) { - SEHemorrhage* myHem = m_Hemorrhages[hem->GetCompartment()]; - if (myHem == nullptr) - { - myHem = new SEHemorrhage(); - m_Hemorrhages[hem->GetCompartment()] = myHem; - } - myHem->Copy(*hem); - if (!myHem->IsActive()) + SEHemorrhage& mine = GetHemorrhage(hem->GetCompartment()); + mine.Copy(*hem, true); + mine.Activate(); + if (!mine.IsActive()) RemoveHemorrhage(hem->GetCompartment()); return true; } @@ -354,9 +368,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEImpairedAlveolarExchangeExacerbation* imaee = dynamic_cast(&action); if (imaee != nullptr) { - if (m_ImpairedAlveolarExchangeExacerbation == nullptr) - m_ImpairedAlveolarExchangeExacerbation = new SEImpairedAlveolarExchangeExacerbation(); - m_ImpairedAlveolarExchangeExacerbation->Copy(*imaee); + GetImpairedAlveolarExchangeExacerbation().Copy(*imaee, true); + m_ImpairedAlveolarExchangeExacerbation->Activate(); if (!m_ImpairedAlveolarExchangeExacerbation->IsActive()) RemoveImpairedAlveolarExchangeExacerbation(); return true; @@ -365,9 +378,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEIntubation* intubation = dynamic_cast(&action); if (intubation != nullptr) { - if (m_Intubation == nullptr) - m_Intubation = new SEIntubation(); - m_Intubation->Copy(*intubation); + GetIntubation().Copy(*intubation, true); + m_Intubation->Activate(); if (!m_Intubation->IsActive()) RemoveIntubation(); return true; @@ -376,9 +388,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SELobarPneumoniaExacerbation* lp = dynamic_cast(&action); if (lp != nullptr) { - if (m_LobarPneumoniaExacerbation == nullptr) - m_LobarPneumoniaExacerbation = new SELobarPneumoniaExacerbation(); - m_LobarPneumoniaExacerbation->Copy(*lp); + GetLobarPneumoniaExacerbation().Copy(*lp, true); + m_LobarPneumoniaExacerbation->Activate(); if (!m_LobarPneumoniaExacerbation->IsActive()) RemoveLobarPneumoniaExacerbation(); return true; @@ -387,9 +398,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEMechanicalVentilation* mvData = dynamic_cast(&action); if (mvData != nullptr) { - if (m_MechanicalVentilation == nullptr) - m_MechanicalVentilation = new SEMechanicalVentilation(); - m_MechanicalVentilation->Copy(*mvData, subMgr); + GetMechanicalVentilation().Copy(*mvData, m_SubMgr, true); + m_MechanicalVentilation->Activate(); if (!m_MechanicalVentilation->IsActive()) RemoveMechanicalVentilation(); return true; @@ -400,18 +410,16 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES { if (needleDecomp->GetSide() == eSide::Left) { - if (m_LeftNeedleDecompression == nullptr) - m_LeftNeedleDecompression = new SENeedleDecompression(); - m_LeftNeedleDecompression->Copy(*needleDecomp); + GetLeftNeedleDecompression().Copy(*needleDecomp, true); + m_LeftNeedleDecompression->Activate(); if (!m_LeftNeedleDecompression->IsActive()) RemoveLeftNeedleDecompression(); return true; } else if (needleDecomp->GetSide() == eSide::Right) { - if (m_RightNeedleDecompression == nullptr) - m_RightNeedleDecompression = new SENeedleDecompression(); - m_RightNeedleDecompression->Copy(*needleDecomp); + GetRightNeedleDecompression().Copy(*needleDecomp, true); + m_RightNeedleDecompression->Activate(); if (!m_RightNeedleDecompression->IsActive()) RemoveRightNeedleDecompression(); return true; @@ -423,9 +431,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEPericardialEffusion* pericardialEff = dynamic_cast(&action); if (pericardialEff != nullptr) { - if (m_PericardialEffusion == nullptr) - m_PericardialEffusion = new SEPericardialEffusion(); - m_PericardialEffusion->Copy(*pericardialEff); + GetPericardialEffusion().Copy(*pericardialEff, true); + m_PericardialEffusion->Activate(); if (!m_PericardialEffusion->IsActive()) RemovePericardialEffusion(); return true; @@ -434,9 +441,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEPulmonaryShuntExacerbation* pulshuntex = dynamic_cast(&action); if (pulshuntex != nullptr) { - if (m_PulmonaryShuntExacerbation == nullptr) - m_PulmonaryShuntExacerbation = new SEPulmonaryShuntExacerbation(); - m_PulmonaryShuntExacerbation->Copy(*pulshuntex); + GetPulmonaryShuntExacerbation().Copy(*pulshuntex, true); + m_PulmonaryShuntExacerbation->Activate(); if (!m_PulmonaryShuntExacerbation->IsActive()) RemovePulmonaryShuntExacerbation(); return true; @@ -445,9 +451,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SERespiratoryFatigue* rf = dynamic_cast(&action); if (rf != nullptr) { - if (m_RespiratoryFatigue == nullptr) - m_RespiratoryFatigue = new SERespiratoryFatigue(); - m_RespiratoryFatigue->Copy(*rf); + GetRespiratoryFatigue().Copy(*rf, true); + m_RespiratoryFatigue->Activate(); if (!m_RespiratoryFatigue->IsActive()) RemoveRespiratoryFatigue(); return true; @@ -456,21 +461,16 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SESubstanceBolus* bolus = dynamic_cast(&action); if (bolus != nullptr) { - const SESubstance* sub = subMgr.GetSubstance(bolus->GetSubstance().GetName()); + const SESubstance* sub = m_SubMgr.GetSubstance(bolus->GetSubstance().GetName()); if (sub == nullptr)//Make sure this substance manager has it { Error("Ignoring SESubstanceBolus action due to unknown substance in action: " + bolus->GetSubstance().GetName()); return false; } - SESubstanceBolus* myBolus = m_SubstanceBolus[sub]; - if (myBolus == nullptr) - { - myBolus = new SESubstanceBolus(*sub); - m_SubstanceBolus[sub] = myBolus; - subMgr.AddActiveSubstance(*sub); - } - myBolus->Copy(*bolus); - if (!myBolus->IsActive()) + SESubstanceBolus& mine = GetSubstanceBolus(*sub); + mine.Copy(*bolus, true); + mine.Activate(); + if (!mine.IsActive()) RemoveSubstanceBolus(*sub); return true; } @@ -478,21 +478,16 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SESubstanceInfusion* subInfusion = dynamic_cast(&action); if (subInfusion != nullptr) { - const SESubstance* sub = subMgr.GetSubstance(subInfusion->GetSubstance().GetName()); + const SESubstance* sub = m_SubMgr.GetSubstance(subInfusion->GetSubstance().GetName()); if (sub == nullptr)//Make sure this substance manager has it { Error("Ignoring SESubstanceInfusion action due to unknown substance in action: " + subInfusion->GetSubstance().GetName()); return false; } - SESubstanceInfusion* mySubInfuse = m_SubstanceInfusions[sub]; - if (mySubInfuse == nullptr) - { - mySubInfuse = new SESubstanceInfusion(*sub); - m_SubstanceInfusions[sub] = mySubInfuse; - subMgr.AddActiveSubstance(*sub); - } - mySubInfuse->Copy(*subInfusion); - if (!mySubInfuse->IsActive()) + SESubstanceInfusion& mine = GetSubstanceInfusion(*sub); + mine.Copy(*subInfusion, true); + mine.Activate(); + if (!mine.IsActive()) RemoveSubstanceInfusion(*sub); return true; } @@ -500,27 +495,16 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SESubstanceCompoundInfusion* cSubInfusion = dynamic_cast(&action); if (cSubInfusion != nullptr) { - const SESubstanceCompound* cmpd = subMgr.GetCompound(cSubInfusion->GetSubstanceCompound().GetName()); + const SESubstanceCompound* cmpd = m_SubMgr.GetCompound(cSubInfusion->GetSubstanceCompound().GetName()); if (cmpd == nullptr)//Make sure this substance manager has it { Error("Ignoring SESubstanceCompoundInfusion action due to unknown substance in action: " + cSubInfusion->GetSubstanceCompound().GetName()); return false; } - SESubstanceCompoundInfusion* mySubCompInfuse = m_SubstanceCompoundInfusions[cmpd]; - if (mySubCompInfuse == nullptr) - { - mySubCompInfuse = new SESubstanceCompoundInfusion(*cmpd); - m_SubstanceCompoundInfusions[cmpd] = mySubCompInfuse; - subMgr.AddActiveCompound(*cmpd); - // Activate the compound component substances - const SESubstanceCompound& sc = mySubCompInfuse->GetSubstanceCompound(); - for (const SESubstanceConcentration* scc : sc.GetComponents()) - { - subMgr.AddActiveSubstance(scc->GetSubstance()); - } - } - mySubCompInfuse->Copy(*cSubInfusion); - if (!mySubCompInfuse->IsActive()) + SESubstanceCompoundInfusion& mine = GetSubstanceCompoundInfusion(*cmpd); + mine.Copy(*cSubInfusion, true); + mine.Activate(); + if (!mine.IsActive()) RemoveSubstanceCompoundInfusion(*cmpd); return true; } @@ -528,9 +512,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SESupplementalOxygen* supplementalO2 = dynamic_cast(&action); if (supplementalO2 != nullptr) { - if (m_SupplementalOxygen == nullptr) - m_SupplementalOxygen = new SESupplementalOxygen(); - m_SupplementalOxygen->Copy(*supplementalO2); + GetSupplementalOxygen().Copy(*supplementalO2, true); + m_SupplementalOxygen->Activate(); if (!m_SupplementalOxygen->IsActive()) RemoveSupplementalOxygen(); return true; @@ -541,36 +524,32 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES { if (pneumo->GetSide() == eSide::Left&&pneumo->GetType() == eGate::Open) { - if (m_LeftOpenTensionPneumothorax == nullptr) - m_LeftOpenTensionPneumothorax = new SETensionPneumothorax(); - m_LeftOpenTensionPneumothorax->Copy(*pneumo); + GetLeftOpenTensionPneumothorax().Copy(*pneumo, true); + m_LeftOpenTensionPneumothorax->Activate(); if (!m_LeftOpenTensionPneumothorax->IsActive()) RemoveLeftOpenTensionPneumothorax(); return true; } else if (pneumo->GetSide() == eSide::Left&&pneumo->GetType() == eGate::Closed) { - if (m_LeftClosedTensionPneumothorax == nullptr) - m_LeftClosedTensionPneumothorax = new SETensionPneumothorax(); - m_LeftClosedTensionPneumothorax->Copy(*pneumo); + GetLeftClosedTensionPneumothorax().Copy(*pneumo, true); + m_LeftClosedTensionPneumothorax->Activate(); if (!m_LeftClosedTensionPneumothorax->IsActive()) RemoveLeftClosedTensionPneumothorax(); return true; } else if (pneumo->GetSide() == eSide::Right&&pneumo->GetType() == eGate::Open) { - if (m_RightOpenTensionPneumothorax == nullptr) - m_RightOpenTensionPneumothorax = new SETensionPneumothorax(); - m_RightOpenTensionPneumothorax->Copy(*pneumo); + GetRightOpenTensionPneumothorax().Copy(*pneumo, true); + m_RightOpenTensionPneumothorax->Activate(); if (!m_RightOpenTensionPneumothorax->IsActive()) RemoveRightOpenTensionPneumothorax(); return true; } else if (pneumo->GetSide() == eSide::Right&&pneumo->GetType() == eGate::Closed) { - if (m_RightClosedTensionPneumothorax == nullptr) - m_RightClosedTensionPneumothorax = new SETensionPneumothorax(); - m_RightClosedTensionPneumothorax->Copy(*pneumo); + GetRightClosedTensionPneumothorax().Copy(*pneumo, true); + m_RightClosedTensionPneumothorax->Activate(); if (!m_RightClosedTensionPneumothorax->IsActive()) RemoveRightClosedTensionPneumothorax(); return true; @@ -582,9 +561,8 @@ bool SEPatientActionCollection::ProcessAction(const SEPatientAction& action, SES const SEUrinate* urinate = dynamic_cast(&action); if (urinate != nullptr) { - if (m_Urinate == nullptr) - m_Urinate = new SEUrinate(); - m_Urinate->Copy(*urinate); + GetUrinate().Copy(*urinate, true); + m_Urinate->Activate(); if (!m_Urinate->IsActive()) RemoveUrinate(); return true; @@ -599,9 +577,11 @@ bool SEPatientActionCollection::HasAcuteRespiratoryDistressSyndromeExacerbation( { return m_ARDSExacerbation == nullptr ? false : m_ARDSExacerbation->IsActive(); } -SEAcuteRespiratoryDistressSyndromeExacerbation* SEPatientActionCollection::GetAcuteRespiratoryDistressSyndromeExacerbation() +SEAcuteRespiratoryDistressSyndromeExacerbation& SEPatientActionCollection::GetAcuteRespiratoryDistressSyndromeExacerbation() { - return m_ARDSExacerbation; + if (m_ARDSExacerbation == nullptr) + m_ARDSExacerbation = new SEAcuteRespiratoryDistressSyndromeExacerbation(); + return *m_ARDSExacerbation; } const SEAcuteRespiratoryDistressSyndromeExacerbation* SEPatientActionCollection::GetAcuteRespiratoryDistressSyndromeExacerbation() const { @@ -609,16 +589,19 @@ const SEAcuteRespiratoryDistressSyndromeExacerbation* SEPatientActionCollection: } void SEPatientActionCollection::RemoveAcuteRespiratoryDistressSyndromeExacerbation() { - SAFE_DELETE(m_ARDSExacerbation); + if(m_ARDSExacerbation) + m_ARDSExacerbation->Deactivate(); } bool SEPatientActionCollection::HasAcuteStress() const { return m_AcuteStress == nullptr ? false : m_AcuteStress->IsActive(); } -SEAcuteStress* SEPatientActionCollection::GetAcuteStress() +SEAcuteStress& SEPatientActionCollection::GetAcuteStress() { - return m_AcuteStress; + if (m_AcuteStress == nullptr) + m_AcuteStress = new SEAcuteStress(); + return *m_AcuteStress; } const SEAcuteStress* SEPatientActionCollection::GetAcuteStress() const { @@ -626,16 +609,19 @@ const SEAcuteStress* SEPatientActionCollection::GetAcuteStress() const } void SEPatientActionCollection::RemoveAcuteStress() { - SAFE_DELETE(m_AcuteStress); + if (m_AcuteStress) + m_AcuteStress->Deactivate(); } bool SEPatientActionCollection::HasAirwayObstruction() const { return m_AirwayObstruction == nullptr ? false : m_AirwayObstruction->IsActive(); } -SEAirwayObstruction* SEPatientActionCollection::GetAirwayObstruction() +SEAirwayObstruction& SEPatientActionCollection::GetAirwayObstruction() { - return m_AirwayObstruction; + if (m_AirwayObstruction == nullptr) + m_AirwayObstruction = new SEAirwayObstruction(); + return *m_AirwayObstruction; } const SEAirwayObstruction* SEPatientActionCollection::GetAirwayObstruction() const { @@ -643,16 +629,19 @@ const SEAirwayObstruction* SEPatientActionCollection::GetAirwayObstruction() con } void SEPatientActionCollection::RemoveAirwayObstruction() { - SAFE_DELETE(m_AirwayObstruction); + if (m_AirwayObstruction) + m_AirwayObstruction->Deactivate(); } bool SEPatientActionCollection::HasAsthmaAttack() const { return m_AsthmaAttack == nullptr ? false : m_AsthmaAttack->IsActive(); } -SEAsthmaAttack* SEPatientActionCollection::GetAsthmaAttack() +SEAsthmaAttack& SEPatientActionCollection::GetAsthmaAttack() { - return m_AsthmaAttack; + if (m_AsthmaAttack == nullptr) + m_AsthmaAttack = new SEAsthmaAttack(); + return *m_AsthmaAttack; } const SEAsthmaAttack* SEPatientActionCollection::GetAsthmaAttack() const { @@ -660,16 +649,19 @@ const SEAsthmaAttack* SEPatientActionCollection::GetAsthmaAttack() const } void SEPatientActionCollection::RemoveAsthmaAttack() { - SAFE_DELETE(m_AsthmaAttack); + if (m_AsthmaAttack) + m_AsthmaAttack->Deactivate(); } bool SEPatientActionCollection::HasBrainInjury() const { return m_BrainInjury == nullptr ? false : m_BrainInjury->IsActive(); } -SEBrainInjury* SEPatientActionCollection::GetBrainInjury() +SEBrainInjury& SEPatientActionCollection::GetBrainInjury() { - return m_BrainInjury; + if (m_BrainInjury == nullptr) + m_BrainInjury = new SEBrainInjury(); + return *m_BrainInjury; } const SEBrainInjury* SEPatientActionCollection::GetBrainInjury() const { @@ -677,16 +669,19 @@ const SEBrainInjury* SEPatientActionCollection::GetBrainInjury() const } void SEPatientActionCollection::RemoveBrainInjury() { - SAFE_DELETE(m_BrainInjury); + if (m_BrainInjury) + m_BrainInjury->Deactivate(); } bool SEPatientActionCollection::HasBronchoconstriction() const { return m_Bronchoconstriction == nullptr ? false : m_Bronchoconstriction->IsActive(); } -SEBronchoconstriction* SEPatientActionCollection::GetBronchoconstriction() +SEBronchoconstriction& SEPatientActionCollection::GetBronchoconstriction() { - return m_Bronchoconstriction; + if (m_Bronchoconstriction == nullptr) + m_Bronchoconstriction = new SEBronchoconstriction(); + return *m_Bronchoconstriction; } const SEBronchoconstriction* SEPatientActionCollection::GetBronchoconstriction() const { @@ -694,16 +689,19 @@ const SEBronchoconstriction* SEPatientActionCollection::GetBronchoconstriction() } void SEPatientActionCollection::RemoveBronchoconstriction() { - SAFE_DELETE(m_Bronchoconstriction); + if (m_Bronchoconstriction) + m_Bronchoconstriction->Deactivate(); } bool SEPatientActionCollection::HasCardiacArrest() const { return m_CardiacArrest == nullptr ? false : m_CardiacArrest->IsActive(); } -SECardiacArrest* SEPatientActionCollection::GetCardiacArrest() +SECardiacArrest& SEPatientActionCollection::GetCardiacArrest() { - return m_CardiacArrest; + if (m_CardiacArrest == nullptr) + m_CardiacArrest = new SECardiacArrest(); + return *m_CardiacArrest; } const SECardiacArrest* SEPatientActionCollection::GetCardiacArrest() const { @@ -711,48 +709,51 @@ const SECardiacArrest* SEPatientActionCollection::GetCardiacArrest() const } void SEPatientActionCollection::RemoveCardiacArrest() { - SAFE_DELETE(m_CardiacArrest); + if (m_CardiacArrest) + m_CardiacArrest->Deactivate(); } bool SEPatientActionCollection::HasChestCompression() const { - return m_ChestCompression == nullptr ? false : m_ChestCompression->IsActive(); -} -void SEPatientActionCollection::RemoveChestCompression() -{ - SAFE_DELETE(m_ChestCompression); + return HasChestCompressionForce() || HasChestCompressionForceScale(); } bool SEPatientActionCollection::HasChestCompressionForce() const { - if (m_ChestCompression == nullptr) - return false; - if (dynamic_cast(m_ChestCompression) == nullptr) - return false; - return m_ChestCompression->IsActive(); + return m_ChestCompressionForce == nullptr ? false : m_ChestCompressionForce->IsActive(); } -SEChestCompressionForce* SEPatientActionCollection::GetChestCompressionForce() +SEChestCompressionForce& SEPatientActionCollection::GetChestCompressionForce() { - return dynamic_cast(m_ChestCompression); + if (m_ChestCompressionForce == nullptr) + m_ChestCompressionForce = new SEChestCompressionForce(); + return *m_ChestCompressionForce; } const SEChestCompressionForce* SEPatientActionCollection::GetChestCompressionForce() const { - return dynamic_cast(m_ChestCompression); + return m_ChestCompressionForce; +} +void SEPatientActionCollection::RemoveChestCompressionForce() +{ + if (m_ChestCompressionForce) + m_ChestCompressionForce->Deactivate(); } bool SEPatientActionCollection::HasChestCompressionForceScale() const { - if (m_ChestCompression == nullptr) - return false; - if (dynamic_cast(m_ChestCompression) == nullptr) - return false; - return m_ChestCompression->IsActive(); + return m_ChestCompressionForceScale == nullptr ? false : m_ChestCompressionForceScale->IsActive(); } -SEChestCompressionForceScale* SEPatientActionCollection::GetChestCompressionForceScale() +SEChestCompressionForceScale& SEPatientActionCollection::GetChestCompressionForceScale() { - return dynamic_cast(m_ChestCompression); + if (m_ChestCompressionForceScale == nullptr) + m_ChestCompressionForceScale = new SEChestCompressionForceScale(); + return *m_ChestCompressionForceScale; } const SEChestCompressionForceScale* SEPatientActionCollection::GetChestCompressionForceScale() const { - return dynamic_cast(m_ChestCompression); + return m_ChestCompressionForceScale; +} +void SEPatientActionCollection::RemoveChestCompressionForceScale() +{ + if (m_ChestCompressionForceScale) + m_ChestCompressionForceScale->Deactivate(); } bool SEPatientActionCollection::HasChestOcclusiveDressing() const @@ -763,9 +764,11 @@ bool SEPatientActionCollection::HasLeftChestOcclusiveDressing() const { return m_LeftChestOcclusiveDressing == nullptr ? false : m_LeftChestOcclusiveDressing->IsActive(); } -SEChestOcclusiveDressing* SEPatientActionCollection::GetLeftChestOcclusiveDressing() +SEChestOcclusiveDressing& SEPatientActionCollection::GetLeftChestOcclusiveDressing() { - return m_LeftChestOcclusiveDressing; + if (m_LeftChestOcclusiveDressing == nullptr) + m_LeftChestOcclusiveDressing = new SEChestOcclusiveDressing(); + return *m_LeftChestOcclusiveDressing; } const SEChestOcclusiveDressing* SEPatientActionCollection::GetLeftChestOcclusiveDressing() const { @@ -773,15 +776,18 @@ const SEChestOcclusiveDressing* SEPatientActionCollection::GetLeftChestOcclusive } void SEPatientActionCollection::RemoveLeftChestOcclusiveDressing() { - SAFE_DELETE(m_LeftChestOcclusiveDressing); + if (m_LeftChestOcclusiveDressing) + m_LeftChestOcclusiveDressing->Deactivate(); } bool SEPatientActionCollection::HasRightChestOcclusiveDressing() const { return m_RightChestOcclusiveDressing == nullptr ? false : m_RightChestOcclusiveDressing->IsActive(); } -SEChestOcclusiveDressing* SEPatientActionCollection::GetRightChestOcclusiveDressing() +SEChestOcclusiveDressing& SEPatientActionCollection::GetRightChestOcclusiveDressing() { - return m_RightChestOcclusiveDressing; + if (m_RightChestOcclusiveDressing == nullptr) + m_RightChestOcclusiveDressing = new SEChestOcclusiveDressing(); + return *m_RightChestOcclusiveDressing; } const SEChestOcclusiveDressing* SEPatientActionCollection::GetRightChestOcclusiveDressing() const { @@ -789,16 +795,19 @@ const SEChestOcclusiveDressing* SEPatientActionCollection::GetRightChestOcclusiv } void SEPatientActionCollection::RemoveRightChestOcclusiveDressing() { - SAFE_DELETE(m_RightChestOcclusiveDressing); + if (m_RightChestOcclusiveDressing) + m_RightChestOcclusiveDressing->Deactivate(); } bool SEPatientActionCollection::HasChronicObstructivePulmonaryDiseaseExacerbation() const { return m_COPDExacerbation == nullptr ? false : m_COPDExacerbation->IsActive(); } -SEChronicObstructivePulmonaryDiseaseExacerbation* SEPatientActionCollection::GetChronicObstructivePulmonaryDiseaseExacerbation() +SEChronicObstructivePulmonaryDiseaseExacerbation& SEPatientActionCollection::GetChronicObstructivePulmonaryDiseaseExacerbation() { - return m_COPDExacerbation; + if (m_COPDExacerbation == nullptr) + m_COPDExacerbation = new SEChronicObstructivePulmonaryDiseaseExacerbation(); + return *m_COPDExacerbation; } const SEChronicObstructivePulmonaryDiseaseExacerbation* SEPatientActionCollection::GetChronicObstructivePulmonaryDiseaseExacerbation() const { @@ -806,16 +815,19 @@ const SEChronicObstructivePulmonaryDiseaseExacerbation* SEPatientActionCollectio } void SEPatientActionCollection::RemoveChronicObstructivePulmonaryDiseaseExacerbation() { - SAFE_DELETE(m_COPDExacerbation); + if (m_COPDExacerbation) + m_COPDExacerbation->Deactivate(); } bool SEPatientActionCollection::HasConsciousRespiration() const { return m_ConsciousRespiration == nullptr ? false : m_ConsciousRespiration->IsActive(); } -SEConsciousRespiration* SEPatientActionCollection::GetConsciousRespiration() +SEConsciousRespiration& SEPatientActionCollection::GetConsciousRespiration() { - return m_ConsciousRespiration; + if (m_ConsciousRespiration == nullptr) + m_ConsciousRespiration = new SEConsciousRespiration(); + return *m_ConsciousRespiration; } const SEConsciousRespiration* SEPatientActionCollection::GetConsciousRespiration() const { @@ -823,16 +835,19 @@ const SEConsciousRespiration* SEPatientActionCollection::GetConsciousRespiration } void SEPatientActionCollection::RemoveConsciousRespiration() { - SAFE_DELETE(m_ConsciousRespiration); + if (m_ConsciousRespiration) + m_ConsciousRespiration->Deactivate(); } bool SEPatientActionCollection::HasConsumeNutrients() const { return m_ConsumeNutrients == nullptr ? false : m_ConsumeNutrients->IsActive(); } -SEConsumeNutrients* SEPatientActionCollection::GetConsumeNutrients() +SEConsumeNutrients& SEPatientActionCollection::GetConsumeNutrients() { - return m_ConsumeNutrients; + if (m_ConsumeNutrients == nullptr) + m_ConsumeNutrients = new SEConsumeNutrients(); + return *m_ConsumeNutrients; } const SEConsumeNutrients* SEPatientActionCollection::GetConsumeNutrients() const { @@ -840,16 +855,19 @@ const SEConsumeNutrients* SEPatientActionCollection::GetConsumeNutrients() const } void SEPatientActionCollection::RemoveConsumeNutrients() { - SAFE_DELETE(m_ConsumeNutrients); + if (m_ConsumeNutrients) + m_ConsumeNutrients->Deactivate(); } bool SEPatientActionCollection::HasDyspnea() const { return m_Dyspnea == nullptr ? false : m_Dyspnea->IsActive(); } -SEDyspnea* SEPatientActionCollection::GetDyspnea() +SEDyspnea& SEPatientActionCollection::GetDyspnea() { - return m_Dyspnea; + if (m_Dyspnea == nullptr) + m_Dyspnea = new SEDyspnea(); + return *m_Dyspnea; } const SEDyspnea* SEPatientActionCollection::GetDyspnea() const { @@ -857,16 +875,19 @@ const SEDyspnea* SEPatientActionCollection::GetDyspnea() const } void SEPatientActionCollection::RemoveDyspnea() { - SAFE_DELETE(m_Dyspnea); + if (m_Dyspnea) + m_Dyspnea->Deactivate(); } bool SEPatientActionCollection::HasExercise() const { return m_Exercise == nullptr ? false : m_Exercise->IsActive(); } -SEExercise* SEPatientActionCollection::GetExercise() +SEExercise& SEPatientActionCollection::GetExercise() { - return m_Exercise; + if (m_Exercise == nullptr) + m_Exercise = new SEExercise(); + return *m_Exercise; } const SEExercise* SEPatientActionCollection::GetExercise() const { @@ -874,31 +895,60 @@ const SEExercise* SEPatientActionCollection::GetExercise() const } void SEPatientActionCollection::RemoveExercise() { - SAFE_DELETE(m_Exercise); + if (m_Exercise) + m_Exercise->Deactivate(); } bool SEPatientActionCollection::HasHemorrhage() const { - return m_Hemorrhages.empty() ? false : true; + for (auto h : m_Hemorrhages) + if (h->IsActive()) + return true; + return false; +} +bool SEPatientActionCollection::HasHemorrhage(const std::string& cmptName) const +{ + return GetHemorrhage(cmptName)!=nullptr; +} +SEHemorrhage& SEPatientActionCollection::GetHemorrhage(const std::string& cmptName) +{ + for (auto h : m_Hemorrhages) + if (h->GetCompartment() == cmptName) + return *h; + SEHemorrhage* h = new SEHemorrhage(); + h->SetCompartment(cmptName); + m_Hemorrhages.push_back(h); + return *h; +} +const SEHemorrhage* SEPatientActionCollection::GetHemorrhage(const std::string& cmptName) const +{ + for (auto h : m_Hemorrhages) + if (h->GetCompartment() == cmptName) + return h; + return nullptr; } -const std::map& SEPatientActionCollection::GetHemorrhages() const +const std::vector& SEPatientActionCollection::GetHemorrhages() { return m_Hemorrhages; } -void SEPatientActionCollection::RemoveHemorrhage(const std::string& cmpt) +const std::vector& SEPatientActionCollection::GetHemorrhages() const { - SEHemorrhage* h = m_Hemorrhages[cmpt]; - m_Hemorrhages.erase(cmpt); - SAFE_DELETE(h); + return *((std::vector*) &m_Hemorrhages); +} +void SEPatientActionCollection::RemoveHemorrhage(const std::string& cmptName) +{ + GetHemorrhage(cmptName).Deactivate(); } bool SEPatientActionCollection::HasImpairedAlveolarExchangeExacerbation() const { return m_ImpairedAlveolarExchangeExacerbation == nullptr ? false : m_ImpairedAlveolarExchangeExacerbation->IsActive(); } -SEImpairedAlveolarExchangeExacerbation* SEPatientActionCollection::GetImpairedAlveolarExchangeExacerbation() +SEImpairedAlveolarExchangeExacerbation& SEPatientActionCollection::GetImpairedAlveolarExchangeExacerbation() { - return m_ImpairedAlveolarExchangeExacerbation; + if (m_ImpairedAlveolarExchangeExacerbation == nullptr) + m_ImpairedAlveolarExchangeExacerbation = new SEImpairedAlveolarExchangeExacerbation(); + return *m_ImpairedAlveolarExchangeExacerbation; } const SEImpairedAlveolarExchangeExacerbation* SEPatientActionCollection::GetImpairedAlveolarExchangeExacerbation() const { @@ -906,16 +956,19 @@ const SEImpairedAlveolarExchangeExacerbation* SEPatientActionCollection::GetImpa } void SEPatientActionCollection::RemoveImpairedAlveolarExchangeExacerbation() { - SAFE_DELETE(m_ImpairedAlveolarExchangeExacerbation); + if (m_ImpairedAlveolarExchangeExacerbation) + m_ImpairedAlveolarExchangeExacerbation->Deactivate(); } bool SEPatientActionCollection::HasIntubation() const { return m_Intubation == nullptr ? false : m_Intubation->IsActive(); } -SEIntubation* SEPatientActionCollection::GetIntubation() +SEIntubation& SEPatientActionCollection::GetIntubation() { - return m_Intubation; + if (m_Intubation == nullptr) + m_Intubation = new SEIntubation(); + return *m_Intubation; } const SEIntubation* SEPatientActionCollection::GetIntubation() const { @@ -923,16 +976,19 @@ const SEIntubation* SEPatientActionCollection::GetIntubation() const } void SEPatientActionCollection::RemoveIntubation() { - SAFE_DELETE(m_Intubation); + if (m_Intubation) + m_Intubation->Deactivate(); } bool SEPatientActionCollection::HasLobarPneumoniaExacerbation() const { return m_LobarPneumoniaExacerbation == nullptr ? false : m_LobarPneumoniaExacerbation->IsActive(); } -SELobarPneumoniaExacerbation* SEPatientActionCollection::GetLobarPneumoniaExacerbation() +SELobarPneumoniaExacerbation& SEPatientActionCollection::GetLobarPneumoniaExacerbation() { - return m_LobarPneumoniaExacerbation; + if (m_LobarPneumoniaExacerbation == nullptr) + m_LobarPneumoniaExacerbation = new SELobarPneumoniaExacerbation(); + return *m_LobarPneumoniaExacerbation; } const SELobarPneumoniaExacerbation* SEPatientActionCollection::GetLobarPneumoniaExacerbation() const { @@ -940,16 +996,19 @@ const SELobarPneumoniaExacerbation* SEPatientActionCollection::GetLobarPneumonia } void SEPatientActionCollection::RemoveLobarPneumoniaExacerbation() { - SAFE_DELETE(m_LobarPneumoniaExacerbation); + if (m_LobarPneumoniaExacerbation) + m_LobarPneumoniaExacerbation->Deactivate(); } bool SEPatientActionCollection::HasMechanicalVentilation() const { return m_MechanicalVentilation == nullptr ? false : m_MechanicalVentilation->IsActive(); } -SEMechanicalVentilation* SEPatientActionCollection::GetMechanicalVentilation() +SEMechanicalVentilation& SEPatientActionCollection::GetMechanicalVentilation() { - return m_MechanicalVentilation; + if (m_MechanicalVentilation == nullptr) + m_MechanicalVentilation = new SEMechanicalVentilation(); + return *m_MechanicalVentilation; } const SEMechanicalVentilation* SEPatientActionCollection::GetMechanicalVentilation() const { @@ -957,7 +1016,8 @@ const SEMechanicalVentilation* SEPatientActionCollection::GetMechanicalVentilati } void SEPatientActionCollection::RemoveMechanicalVentilation() { - SAFE_DELETE(m_MechanicalVentilation); + if (m_MechanicalVentilation) + m_MechanicalVentilation->Deactivate(); } bool SEPatientActionCollection::HasNeedleDecompression() const @@ -968,9 +1028,11 @@ bool SEPatientActionCollection::HasLeftNeedleDecompression() const { return m_LeftNeedleDecompression == nullptr ? false : m_LeftNeedleDecompression->IsActive(); } -SENeedleDecompression* SEPatientActionCollection::GetLeftNeedleDecompression() +SENeedleDecompression& SEPatientActionCollection::GetLeftNeedleDecompression() { - return m_LeftNeedleDecompression; + if (m_LeftNeedleDecompression == nullptr) + m_LeftNeedleDecompression = new SENeedleDecompression(); + return *m_LeftNeedleDecompression; } const SENeedleDecompression* SEPatientActionCollection::GetLeftNeedleDecompression() const { @@ -978,15 +1040,18 @@ const SENeedleDecompression* SEPatientActionCollection::GetLeftNeedleDecompressi } void SEPatientActionCollection::RemoveLeftNeedleDecompression() { - SAFE_DELETE(m_LeftNeedleDecompression); + if (m_LeftNeedleDecompression) + m_LeftNeedleDecompression->Deactivate(); } bool SEPatientActionCollection::HasRightNeedleDecompression() const { return m_RightNeedleDecompression == nullptr ? false : m_RightNeedleDecompression->IsActive(); } -SENeedleDecompression* SEPatientActionCollection::GetRightNeedleDecompression() +SENeedleDecompression& SEPatientActionCollection::GetRightNeedleDecompression() { - return m_RightNeedleDecompression; + if (m_RightNeedleDecompression == nullptr) + m_RightNeedleDecompression = new SENeedleDecompression(); + return *m_RightNeedleDecompression; } const SENeedleDecompression* SEPatientActionCollection::GetRightNeedleDecompression() const { @@ -994,16 +1059,19 @@ const SENeedleDecompression* SEPatientActionCollection::GetRightNeedleDecompress } void SEPatientActionCollection::RemoveRightNeedleDecompression() { - SAFE_DELETE(m_RightNeedleDecompression); + if (m_RightNeedleDecompression) + m_RightNeedleDecompression->Deactivate(); } bool SEPatientActionCollection::HasPericardialEffusion() const { return m_PericardialEffusion == nullptr ? false : m_PericardialEffusion->IsActive(); } -SEPericardialEffusion* SEPatientActionCollection::GetPericardialEffusion() +SEPericardialEffusion& SEPatientActionCollection::GetPericardialEffusion() { - return m_PericardialEffusion; + if (m_PericardialEffusion == nullptr) + m_PericardialEffusion = new SEPericardialEffusion(); + return *m_PericardialEffusion; } const SEPericardialEffusion* SEPatientActionCollection::GetPericardialEffusion() const { @@ -1011,16 +1079,19 @@ const SEPericardialEffusion* SEPatientActionCollection::GetPericardialEffusion() } void SEPatientActionCollection::RemovePericardialEffusion() { - SAFE_DELETE(m_PericardialEffusion); + if (m_PericardialEffusion) + m_PericardialEffusion->Deactivate(); } bool SEPatientActionCollection::HasPulmonaryShuntExacerbation() const { return m_PulmonaryShuntExacerbation == nullptr ? false : m_PulmonaryShuntExacerbation->IsActive(); } -SEPulmonaryShuntExacerbation* SEPatientActionCollection::GetPulmonaryShuntExacerbation() +SEPulmonaryShuntExacerbation& SEPatientActionCollection::GetPulmonaryShuntExacerbation() { - return m_PulmonaryShuntExacerbation; + if (m_PulmonaryShuntExacerbation == nullptr) + m_PulmonaryShuntExacerbation = new SEPulmonaryShuntExacerbation(); + return *m_PulmonaryShuntExacerbation; } const SEPulmonaryShuntExacerbation* SEPatientActionCollection::GetPulmonaryShuntExacerbation() const { @@ -1028,16 +1099,19 @@ const SEPulmonaryShuntExacerbation* SEPatientActionCollection::GetPulmonaryShunt } void SEPatientActionCollection::RemovePulmonaryShuntExacerbation() { - SAFE_DELETE(m_PulmonaryShuntExacerbation); + if (m_PulmonaryShuntExacerbation) + m_PulmonaryShuntExacerbation->Deactivate(); } bool SEPatientActionCollection::HasRespiratoryFatigue() const { return m_RespiratoryFatigue == nullptr ? false : m_RespiratoryFatigue->IsActive(); } -SERespiratoryFatigue* SEPatientActionCollection::GetRespiratoryFatigue() +SERespiratoryFatigue& SEPatientActionCollection::GetRespiratoryFatigue() { - return m_RespiratoryFatigue; + if (m_RespiratoryFatigue == nullptr) + m_RespiratoryFatigue = new SERespiratoryFatigue(); + return *m_RespiratoryFatigue; } const SERespiratoryFatigue* SEPatientActionCollection::GetRespiratoryFatigue() const { @@ -1045,16 +1119,19 @@ const SERespiratoryFatigue* SEPatientActionCollection::GetRespiratoryFatigue() c } void SEPatientActionCollection::RemoveRespiratoryFatigue() { - SAFE_DELETE(m_RespiratoryFatigue); + if (m_RespiratoryFatigue) + m_RespiratoryFatigue->Deactivate(); } bool SEPatientActionCollection::HasSupplementalOxygen() const { return m_SupplementalOxygen == nullptr ? false : m_SupplementalOxygen->IsActive(); } -SESupplementalOxygen* SEPatientActionCollection::GetSupplementalOxygen() +SESupplementalOxygen& SEPatientActionCollection::GetSupplementalOxygen() { - return m_SupplementalOxygen; + if (m_SupplementalOxygen == nullptr) + m_SupplementalOxygen = new SESupplementalOxygen(); + return *m_SupplementalOxygen; } const SESupplementalOxygen* SEPatientActionCollection::GetSupplementalOxygen() const { @@ -1062,40 +1139,136 @@ const SESupplementalOxygen* SEPatientActionCollection::GetSupplementalOxygen() c } void SEPatientActionCollection::RemoveSupplementalOxygen() { - SAFE_DELETE(m_SupplementalOxygen); + if (m_SupplementalOxygen) + m_SupplementalOxygen->Deactivate(); } -const std::map& SEPatientActionCollection::GetSubstanceBoluses() const +bool SEPatientActionCollection::HasSubstanceBolus() const +{ + for (auto h : m_SubstanceBoluses) + if (h->IsActive()) + return true; + return false; +} +bool SEPatientActionCollection::HasSubstanceBolus(const SESubstance& sub) const +{ + return GetSubstanceBolus(sub) != nullptr; +} +SESubstanceBolus& SEPatientActionCollection::GetSubstanceBolus(const SESubstance& sub) +{ + for (auto b : m_SubstanceBoluses) + if (&b->GetSubstance() == &sub) + return *b; + SESubstanceBolus* b = new SESubstanceBolus(sub); + m_SubstanceBoluses.push_back(b); + m_SubMgr.AddActiveSubstance(sub); + return *b; +} +const SESubstanceBolus* SEPatientActionCollection::GetSubstanceBolus(const SESubstance& sub) const { - return m_SubstanceBolus; + for (auto b : m_SubstanceBoluses) + if (&b->GetSubstance() == &sub) + return b; + return nullptr; +} +const std::vector& SEPatientActionCollection::GetSubstanceBoluses() +{ + return m_SubstanceBoluses; +} +const std::vector& SEPatientActionCollection::GetSubstanceBoluses() const +{ + return *((std::vector*) & m_SubstanceBoluses); } void SEPatientActionCollection::RemoveSubstanceBolus(const SESubstance& sub) { - SESubstanceBolus* b = m_SubstanceBolus[&sub]; - m_SubstanceBolus.erase(&sub); - SAFE_DELETE(b); + GetSubstanceBolus(sub).Deactivate(); } -const std::map& SEPatientActionCollection::GetSubstanceInfusions() const +bool SEPatientActionCollection::HasSubstanceInfusion() const +{ + for (auto h : m_SubstanceInfusions) + if (h->IsActive()) + return true; + return false; +} +bool SEPatientActionCollection::HasSubstanceInfusion(const SESubstance& sub) const +{ + return GetSubstanceInfusion(sub) != nullptr; +} +SESubstanceInfusion& SEPatientActionCollection::GetSubstanceInfusion(const SESubstance& sub) +{ + for (auto si : m_SubstanceInfusions) + if (&si->GetSubstance() == &sub) + return *si; + SESubstanceInfusion* si = new SESubstanceInfusion(sub); + m_SubstanceInfusions.push_back(si); + m_SubMgr.AddActiveSubstance(sub); + return *si; +} +const SESubstanceInfusion* SEPatientActionCollection::GetSubstanceInfusion(const SESubstance& sub) const +{ + for (auto si : m_SubstanceInfusions) + if (&si->GetSubstance() == &sub) + return si; + return nullptr; +} +const std::vector& SEPatientActionCollection::GetSubstanceInfusions() { return m_SubstanceInfusions; } +const std::vector& SEPatientActionCollection::GetSubstanceInfusions() const +{ + return *((std::vector*)&m_SubstanceInfusions); +} void SEPatientActionCollection::RemoveSubstanceInfusion(const SESubstance& sub) { - SESubstanceInfusion* si = m_SubstanceInfusions[&sub]; - m_SubstanceInfusions.erase(&sub); - SAFE_DELETE(si); + GetSubstanceInfusion(sub).Deactivate(); } -const std::map& SEPatientActionCollection::GetSubstanceCompoundInfusions() const +bool SEPatientActionCollection::HasSubstanceCompoundInfusion() const +{ + for (auto h : m_SubstanceCompoundInfusions) + if (h->IsActive()) + return true; + return false; +} +bool SEPatientActionCollection::HasSubstanceCompoundInfusion(const SESubstanceCompound& cmpd) const +{ + return GetSubstanceCompoundInfusion(cmpd) != nullptr; +} +SESubstanceCompoundInfusion& SEPatientActionCollection::GetSubstanceCompoundInfusion(const SESubstanceCompound& cmpd) +{ + for (auto sci : m_SubstanceCompoundInfusions) + if (&sci->GetSubstanceCompound() == &cmpd) + return *sci; + SESubstanceCompoundInfusion* sci = new SESubstanceCompoundInfusion(cmpd); + m_SubstanceCompoundInfusions.push_back(sci); + + m_SubMgr.AddActiveCompound(cmpd); + for (const SESubstanceConcentration* scc : cmpd.GetComponents()) + { + m_SubMgr.AddActiveSubstance(scc->GetSubstance()); + } + return *sci; +} +const SESubstanceCompoundInfusion* SEPatientActionCollection::GetSubstanceCompoundInfusion(const SESubstanceCompound& cmpd) const +{ + for (auto sci : m_SubstanceCompoundInfusions) + if (&sci->GetSubstanceCompound() == &cmpd) + return sci; + return nullptr; +} +const std::vector& SEPatientActionCollection::GetSubstanceCompoundInfusions() { return m_SubstanceCompoundInfusions; } -void SEPatientActionCollection::RemoveSubstanceCompoundInfusion(const SESubstanceCompound& cSub) +const std::vector& SEPatientActionCollection::GetSubstanceCompoundInfusions() const +{ + return *((std::vector*) & m_SubstanceCompoundInfusions); +} +void SEPatientActionCollection::RemoveSubstanceCompoundInfusion(const SESubstanceCompound& sub) { - SESubstanceCompoundInfusion* sci = m_SubstanceCompoundInfusions[&cSub]; - m_SubstanceCompoundInfusions.erase(&cSub); - SAFE_DELETE(sci); + GetSubstanceCompoundInfusion(sub).Deactivate(); } bool SEPatientActionCollection::HasTensionPneumothorax() const @@ -1116,9 +1289,11 @@ bool SEPatientActionCollection::HasLeftOpenTensionPneumothorax() const return true; return false; } -SETensionPneumothorax* SEPatientActionCollection::GetLeftOpenTensionPneumothorax() +SETensionPneumothorax& SEPatientActionCollection::GetLeftOpenTensionPneumothorax() { - return m_LeftOpenTensionPneumothorax; + if (m_LeftOpenTensionPneumothorax == nullptr) + m_LeftOpenTensionPneumothorax = new SETensionPneumothorax(); + return *m_LeftOpenTensionPneumothorax; } const SETensionPneumothorax* SEPatientActionCollection::GetLeftOpenTensionPneumothorax() const { @@ -1126,7 +1301,8 @@ const SETensionPneumothorax* SEPatientActionCollection::GetLeftOpenTensionPneumo } void SEPatientActionCollection::RemoveLeftOpenTensionPneumothorax() { - SAFE_DELETE(m_LeftOpenTensionPneumothorax); + if (m_LeftOpenTensionPneumothorax) + m_LeftOpenTensionPneumothorax->Deactivate(); } bool SEPatientActionCollection::HasLeftClosedTensionPneumothorax() const { @@ -1134,9 +1310,11 @@ bool SEPatientActionCollection::HasLeftClosedTensionPneumothorax() const return true; return false; } -SETensionPneumothorax* SEPatientActionCollection::GetLeftClosedTensionPneumothorax() +SETensionPneumothorax& SEPatientActionCollection::GetLeftClosedTensionPneumothorax() { - return m_LeftClosedTensionPneumothorax; + if (m_LeftClosedTensionPneumothorax == nullptr) + m_LeftClosedTensionPneumothorax = new SETensionPneumothorax(); + return *m_LeftClosedTensionPneumothorax; } const SETensionPneumothorax* SEPatientActionCollection::GetLeftClosedTensionPneumothorax() const { @@ -1144,7 +1322,8 @@ const SETensionPneumothorax* SEPatientActionCollection::GetLeftClosedTensionPneu } void SEPatientActionCollection::RemoveLeftClosedTensionPneumothorax() { - SAFE_DELETE(m_LeftClosedTensionPneumothorax); + if (m_LeftClosedTensionPneumothorax) + m_LeftClosedTensionPneumothorax->Deactivate(); } bool SEPatientActionCollection::HasRightOpenTensionPneumothorax() const { @@ -1152,9 +1331,11 @@ bool SEPatientActionCollection::HasRightOpenTensionPneumothorax() const return true; return false; } -SETensionPneumothorax* SEPatientActionCollection::GetRightOpenTensionPneumothorax() +SETensionPneumothorax& SEPatientActionCollection::GetRightOpenTensionPneumothorax() { - return m_RightOpenTensionPneumothorax; + if (m_RightOpenTensionPneumothorax == nullptr) + m_RightOpenTensionPneumothorax = new SETensionPneumothorax(); + return *m_RightOpenTensionPneumothorax; } const SETensionPneumothorax* SEPatientActionCollection::GetRightOpenTensionPneumothorax() const { @@ -1162,7 +1343,8 @@ const SETensionPneumothorax* SEPatientActionCollection::GetRightOpenTensionPneum } void SEPatientActionCollection::RemoveRightOpenTensionPneumothorax() { - SAFE_DELETE(m_RightOpenTensionPneumothorax); + if (m_RightOpenTensionPneumothorax) + m_RightOpenTensionPneumothorax->Deactivate(); } bool SEPatientActionCollection::HasRightClosedTensionPneumothorax() const { @@ -1170,9 +1352,11 @@ bool SEPatientActionCollection::HasRightClosedTensionPneumothorax() const return true; return false; } -SETensionPneumothorax* SEPatientActionCollection::GetRightClosedTensionPneumothorax() +SETensionPneumothorax& SEPatientActionCollection::GetRightClosedTensionPneumothorax() { - return m_RightClosedTensionPneumothorax; + if (m_RightClosedTensionPneumothorax == nullptr) + m_RightClosedTensionPneumothorax = new SETensionPneumothorax(); + return *m_RightClosedTensionPneumothorax; } const SETensionPneumothorax* SEPatientActionCollection::GetRightClosedTensionPneumothorax() const { @@ -1180,16 +1364,19 @@ const SETensionPneumothorax* SEPatientActionCollection::GetRightClosedTensionPne } void SEPatientActionCollection::RemoveRightClosedTensionPneumothorax() { - SAFE_DELETE(m_RightClosedTensionPneumothorax); + if (m_RightClosedTensionPneumothorax) + m_RightClosedTensionPneumothorax->Deactivate(); } bool SEPatientActionCollection::HasUrinate() const { return m_Urinate == nullptr ? false : m_Urinate->IsActive(); } -SEUrinate* SEPatientActionCollection::GetUrinate() +SEUrinate& SEPatientActionCollection::GetUrinate() { - return m_Urinate; + if (m_Urinate == nullptr) + m_Urinate = new SEUrinate(); + return *m_Urinate; } const SEUrinate* SEPatientActionCollection::GetUrinate() const { @@ -1197,7 +1384,8 @@ const SEUrinate* SEPatientActionCollection::GetUrinate() const } void SEPatientActionCollection::RemoveUrinate() { - SAFE_DELETE(m_Urinate); + if (m_Urinate) + m_Urinate->Deactivate(); } void SEPatientActionCollection::GetAllActions(std::vector& actions) const @@ -1234,8 +1422,11 @@ void SEPatientActionCollection::GetAllActions(std::vector& acti actions.push_back(GetDyspnea()); if (HasExercise()) actions.push_back(GetExercise()); - for (auto itr : m_Hemorrhages) - actions.push_back(itr.second); + for (auto a : m_Hemorrhages) + { + if(a->IsActive()) + actions.push_back(a); + } if (HasImpairedAlveolarExchangeExacerbation()) actions.push_back(GetImpairedAlveolarExchangeExacerbation()); if (HasIntubation()) @@ -1262,12 +1453,119 @@ void SEPatientActionCollection::GetAllActions(std::vector& acti actions.push_back(GetRightClosedTensionPneumothorax()); if (HasRightOpenTensionPneumothorax()) actions.push_back(GetRightOpenTensionPneumothorax()); - for (auto itr : m_SubstanceBolus) - actions.push_back(itr.second); - for (auto itr : m_SubstanceInfusions) - actions.push_back(itr.second); - for (auto itr : m_SubstanceCompoundInfusions) - actions.push_back(itr.second); + for (auto a : m_SubstanceBoluses) + { + if (a->IsActive()) + actions.push_back(a); + } + for (auto a : m_SubstanceInfusions) + { + if (a->IsActive()) + actions.push_back(a); + } + for (auto a : m_SubstanceCompoundInfusions) + { + if (a->IsActive()) + actions.push_back(a); + } if (HasUrinate()) actions.push_back(GetUrinate()); -} \ No newline at end of file +} + +const SEScalar* SEPatientActionCollection::GetScalar(const std::string& actionName, const std::string& cmptName, const std::string& substance, const std::string& property) +{ + if (actionName == "AcuteRespiratoryDistressSyndromeExacerbation") + return GetAcuteRespiratoryDistressSyndromeExacerbation().GetScalar(property); + if (actionName == "AcuteStress") + return GetAcuteStress().GetScalar(property); + if (actionName == "AirwayObstruction") + return GetAirwayObstruction().GetScalar(property); + if (actionName == "AsthmaAttack") + return GetAsthmaAttack().GetScalar(property); + if (actionName == "BrainInjury") + return GetBrainInjury().GetScalar(property); + if (actionName == "Bronchoconstriction") + return GetBronchoconstriction().GetScalar(property); + if (actionName == "CardiacArrest") + return GetCardiacArrest().GetScalar(property); + if (actionName == "ChestCompressionForce") + return GetChestCompressionForce().GetScalar(property); + if (actionName == "ChestCompressionForceScale") + return GetChestCompressionForceScale().GetScalar(property); + if (actionName == "LeftChestOcclusiveDressing") + return GetLeftChestOcclusiveDressing().GetScalar(property); + if (actionName == "RightChestOcclusiveDressing") + return GetRightChestOcclusiveDressing().GetScalar(property); + if (actionName == "ChronicObstructivePulmonaryDiseaseExacerbation") + return GetChronicObstructivePulmonaryDiseaseExacerbation().GetScalar(property); + if (actionName == "ConsciousRespiration") + return GetConsciousRespiration().GetScalar(property); + if (actionName == "ConsumeNutrients") + return GetConsumeNutrients().GetScalar(property); + if (actionName == "Dyspnea") + return GetDyspnea().GetScalar(property); + if (actionName == "Exercise") + return GetExercise().GetScalar(property); + if (actionName == "Hemorrhage") + return GetHemorrhage(cmptName).GetScalar(property); + if (actionName == "ImpairedAlveolarExchangeExacerbation") + return GetImpairedAlveolarExchangeExacerbation().GetScalar(property); + if (actionName == "Intubation") + return GetIntubation().GetScalar(property); + if (actionName == "LobarPneumoniaExacerbation") + return GetLobarPneumoniaExacerbation().GetScalar(property); + if (actionName == "MechanicalVentilation") + return GetMechanicalVentilation().GetScalar(property); + if (actionName == "LeftNeedleDecompression") + return GetLeftNeedleDecompression().GetScalar(property); + if (actionName == "RightNeedleDecompression") + return GetRightNeedleDecompression().GetScalar(property); + if (actionName == "PericardialEffusion") + return GetPericardialEffusion().GetScalar(property); + if (actionName == "PulmonaryShuntExacerbation") + return GetPulmonaryShuntExacerbation().GetScalar(property); + if (actionName == "RespiratoryFatigue") + return GetRespiratoryFatigue().GetScalar(property); + if (actionName == "LeftClosedTensionPneumothorax") + return GetLeftClosedTensionPneumothorax().GetScalar(property); + if (actionName == "LeftOpenTensionPneumothorax") + return GetLeftOpenTensionPneumothorax().GetScalar(property); + if (actionName == "RightClosedTensionPneumothorax") + return GetRightClosedTensionPneumothorax().GetScalar(property); + if (actionName == "RightOpenTensionPneumothorax") + return GetRightOpenTensionPneumothorax().GetScalar(property); + if (actionName == "SubstanceBolus") + { + SESubstance* sub = m_SubMgr.GetSubstance(substance); + if (sub == nullptr) + { + Error("Unknown substance : " + substance); + return nullptr; + } + return GetSubstanceBolus(*sub).GetScalar(property); + } + if (actionName == "SubstanceInfusion") + { + SESubstance* sub = m_SubMgr.GetSubstance(substance); + if (sub == nullptr) + { + Error("Unknown substance : " + substance); + return nullptr; + } + return GetSubstanceInfusion(*sub).GetScalar(property); + } + if (actionName == "SubstanceCompoundInfusion") + { + SESubstanceCompound* cmpd = m_SubMgr.GetCompound(substance); + if (cmpd == nullptr) + { + Error("Unknown substance compound : " + substance); + return nullptr; + } + return GetSubstanceCompoundInfusion(*cmpd).GetScalar(property); + } + if (actionName == "Urinate") + return GetUrinate().GetScalar(property); + + return nullptr; +} diff --git a/src/cpp/cdm/engine/SEPatientActionCollection.h b/src/cpp/cdm/engine/SEPatientActionCollection.h index 6343d5b9adf52468894892c5367ab196d73aaf37..2a2ab0eefe7821932ee09a5941603d42a1454d6e 100644 --- a/src/cpp/cdm/engine/SEPatientActionCollection.h +++ b/src/cpp/cdm/engine/SEPatientActionCollection.h @@ -45,185 +45,208 @@ class CDM_DECL SEPatientActionCollection : public Loggable friend class PBEngine;//friend the serialization class friend class SEActionManager; protected: - SEPatientActionCollection(Logger* logger=nullptr); + SEPatientActionCollection(SESubstanceManager& subMgr); public: ~SEPatientActionCollection(); bool HasAcuteRespiratoryDistressSyndromeExacerbation() const; - SEAcuteRespiratoryDistressSyndromeExacerbation* GetAcuteRespiratoryDistressSyndromeExacerbation(); + SEAcuteRespiratoryDistressSyndromeExacerbation& GetAcuteRespiratoryDistressSyndromeExacerbation(); const SEAcuteRespiratoryDistressSyndromeExacerbation* GetAcuteRespiratoryDistressSyndromeExacerbation() const; void RemoveAcuteRespiratoryDistressSyndromeExacerbation(); bool HasAcuteStress() const; - SEAcuteStress* GetAcuteStress(); + SEAcuteStress& GetAcuteStress(); const SEAcuteStress* GetAcuteStress() const; void RemoveAcuteStress(); bool HasAirwayObstruction() const; - SEAirwayObstruction* GetAirwayObstruction(); + SEAirwayObstruction& GetAirwayObstruction(); const SEAirwayObstruction* GetAirwayObstruction() const; void RemoveAirwayObstruction(); bool HasAsthmaAttack() const; - SEAsthmaAttack* GetAsthmaAttack(); + SEAsthmaAttack& GetAsthmaAttack(); const SEAsthmaAttack* GetAsthmaAttack() const; void RemoveAsthmaAttack(); bool HasBrainInjury() const; - SEBrainInjury* GetBrainInjury(); + SEBrainInjury& GetBrainInjury(); const SEBrainInjury* GetBrainInjury() const; void RemoveBrainInjury(); bool HasBronchoconstriction() const; - SEBronchoconstriction* GetBronchoconstriction(); + SEBronchoconstriction& GetBronchoconstriction(); const SEBronchoconstriction* GetBronchoconstriction() const; void RemoveBronchoconstriction(); bool HasCardiacArrest() const; - SECardiacArrest* GetCardiacArrest(); + SECardiacArrest& GetCardiacArrest(); const SECardiacArrest* GetCardiacArrest() const; void RemoveCardiacArrest(); bool HasChestCompression() const; - void RemoveChestCompression(); bool HasChestCompressionForce() const; - SEChestCompressionForce* GetChestCompressionForce(); + SEChestCompressionForce& GetChestCompressionForce(); const SEChestCompressionForce* GetChestCompressionForce() const; + void RemoveChestCompressionForce(); bool HasChestCompressionForceScale() const; - SEChestCompressionForceScale* GetChestCompressionForceScale(); + SEChestCompressionForceScale& GetChestCompressionForceScale(); const SEChestCompressionForceScale* GetChestCompressionForceScale() const; + void RemoveChestCompressionForceScale(); bool HasChestOcclusiveDressing() const; bool HasLeftChestOcclusiveDressing() const; - SEChestOcclusiveDressing* GetLeftChestOcclusiveDressing(); + SEChestOcclusiveDressing& GetLeftChestOcclusiveDressing(); const SEChestOcclusiveDressing* GetLeftChestOcclusiveDressing() const; void RemoveLeftChestOcclusiveDressing(); bool HasRightChestOcclusiveDressing() const; - SEChestOcclusiveDressing* GetRightChestOcclusiveDressing(); + SEChestOcclusiveDressing& GetRightChestOcclusiveDressing(); const SEChestOcclusiveDressing* GetRightChestOcclusiveDressing() const; void RemoveRightChestOcclusiveDressing(); bool HasChronicObstructivePulmonaryDiseaseExacerbation() const; - SEChronicObstructivePulmonaryDiseaseExacerbation* GetChronicObstructivePulmonaryDiseaseExacerbation(); + SEChronicObstructivePulmonaryDiseaseExacerbation& GetChronicObstructivePulmonaryDiseaseExacerbation(); const SEChronicObstructivePulmonaryDiseaseExacerbation* GetChronicObstructivePulmonaryDiseaseExacerbation() const; void RemoveChronicObstructivePulmonaryDiseaseExacerbation(); bool HasConsciousRespiration() const; - SEConsciousRespiration* GetConsciousRespiration(); + SEConsciousRespiration& GetConsciousRespiration(); const SEConsciousRespiration* GetConsciousRespiration() const; void RemoveConsciousRespiration(); bool HasConsumeNutrients() const; - SEConsumeNutrients* GetConsumeNutrients(); + SEConsumeNutrients& GetConsumeNutrients(); const SEConsumeNutrients* GetConsumeNutrients() const; void RemoveConsumeNutrients(); bool HasDyspnea() const; - SEDyspnea* GetDyspnea(); + SEDyspnea& GetDyspnea(); const SEDyspnea* GetDyspnea() const; void RemoveDyspnea(); bool HasExercise() const; - SEExercise* GetExercise(); + SEExercise& GetExercise(); const SEExercise* GetExercise() const; void RemoveExercise(); bool HasHemorrhage() const; - const std::map& GetHemorrhages() const; - void RemoveHemorrhage(const std::string& cmpt); + bool HasHemorrhage(const std::string& cmptName) const; + SEHemorrhage& GetHemorrhage(const std::string& cmptName); + const SEHemorrhage* GetHemorrhage(const std::string& cmptName) const; + const std::vector& GetHemorrhages(); + const std::vector& GetHemorrhages() const; + void RemoveHemorrhage(const std::string& cmptName); bool HasImpairedAlveolarExchangeExacerbation() const; - SEImpairedAlveolarExchangeExacerbation* GetImpairedAlveolarExchangeExacerbation(); + SEImpairedAlveolarExchangeExacerbation& GetImpairedAlveolarExchangeExacerbation(); const SEImpairedAlveolarExchangeExacerbation* GetImpairedAlveolarExchangeExacerbation() const; void RemoveImpairedAlveolarExchangeExacerbation(); bool HasIntubation() const; - SEIntubation* GetIntubation(); + SEIntubation& GetIntubation(); const SEIntubation* GetIntubation() const; void RemoveIntubation(); bool HasLobarPneumoniaExacerbation() const; - SELobarPneumoniaExacerbation* GetLobarPneumoniaExacerbation(); + SELobarPneumoniaExacerbation& GetLobarPneumoniaExacerbation(); const SELobarPneumoniaExacerbation* GetLobarPneumoniaExacerbation() const; void RemoveLobarPneumoniaExacerbation(); bool HasMechanicalVentilation() const; - SEMechanicalVentilation* GetMechanicalVentilation(); + SEMechanicalVentilation& GetMechanicalVentilation(); const SEMechanicalVentilation* GetMechanicalVentilation() const; void RemoveMechanicalVentilation(); bool HasNeedleDecompression() const; bool HasLeftNeedleDecompression() const; - SENeedleDecompression* GetLeftNeedleDecompression(); + SENeedleDecompression& GetLeftNeedleDecompression(); const SENeedleDecompression* GetLeftNeedleDecompression() const; void RemoveLeftNeedleDecompression(); bool HasRightNeedleDecompression() const; - SENeedleDecompression* GetRightNeedleDecompression(); + SENeedleDecompression& GetRightNeedleDecompression(); const SENeedleDecompression* GetRightNeedleDecompression() const; void RemoveRightNeedleDecompression(); bool HasPericardialEffusion() const; - SEPericardialEffusion* GetPericardialEffusion(); + SEPericardialEffusion& GetPericardialEffusion(); const SEPericardialEffusion* GetPericardialEffusion() const; void RemovePericardialEffusion(); bool HasPulmonaryShuntExacerbation() const; - SEPulmonaryShuntExacerbation* GetPulmonaryShuntExacerbation(); + SEPulmonaryShuntExacerbation& GetPulmonaryShuntExacerbation(); const SEPulmonaryShuntExacerbation* GetPulmonaryShuntExacerbation() const; void RemovePulmonaryShuntExacerbation(); bool HasRespiratoryFatigue() const; - SERespiratoryFatigue* GetRespiratoryFatigue(); + SERespiratoryFatigue& GetRespiratoryFatigue(); const SERespiratoryFatigue* GetRespiratoryFatigue() const; void RemoveRespiratoryFatigue(); - const std::map& GetSubstanceBoluses() const; + bool HasSubstanceBolus() const; + bool HasSubstanceBolus(const SESubstance& sub) const; + SESubstanceBolus& GetSubstanceBolus(const SESubstance& sub); + const SESubstanceBolus* GetSubstanceBolus(const SESubstance& sub) const; + const std::vector& GetSubstanceBoluses(); + const std::vector& GetSubstanceBoluses() const; void RemoveSubstanceBolus(const SESubstance& sub); - const std::map& GetSubstanceInfusions() const; + bool HasSubstanceInfusion() const; + bool HasSubstanceInfusion(const SESubstance& sub) const; + SESubstanceInfusion& GetSubstanceInfusion(const SESubstance& sub); + const SESubstanceInfusion* GetSubstanceInfusion(const SESubstance& sub) const; + const std::vector& GetSubstanceInfusions(); + const std::vector& GetSubstanceInfusions() const; void RemoveSubstanceInfusion(const SESubstance& sub); - const std::map& GetSubstanceCompoundInfusions() const; + bool HasSubstanceCompoundInfusion() const; + bool HasSubstanceCompoundInfusion(const SESubstanceCompound& sub) const; + SESubstanceCompoundInfusion& GetSubstanceCompoundInfusion(const SESubstanceCompound& sub); + const SESubstanceCompoundInfusion* GetSubstanceCompoundInfusion(const SESubstanceCompound& sub) const; + const std::vector& GetSubstanceCompoundInfusions(); + const std::vector& GetSubstanceCompoundInfusions() const; void RemoveSubstanceCompoundInfusion(const SESubstanceCompound& sub); bool HasSupplementalOxygen() const; - SESupplementalOxygen* GetSupplementalOxygen(); + SESupplementalOxygen& GetSupplementalOxygen(); const SESupplementalOxygen* GetSupplementalOxygen() const; void RemoveSupplementalOxygen(); bool HasTensionPneumothorax() const; bool HasLeftClosedTensionPneumothorax() const; - SETensionPneumothorax* GetLeftClosedTensionPneumothorax(); + SETensionPneumothorax& GetLeftClosedTensionPneumothorax(); const SETensionPneumothorax* GetLeftClosedTensionPneumothorax() const; void RemoveLeftClosedTensionPneumothorax(); bool HasLeftOpenTensionPneumothorax() const; - SETensionPneumothorax* GetLeftOpenTensionPneumothorax(); + SETensionPneumothorax& GetLeftOpenTensionPneumothorax(); const SETensionPneumothorax* GetLeftOpenTensionPneumothorax() const; void RemoveLeftOpenTensionPneumothorax(); bool HasRightClosedTensionPneumothorax() const; - SETensionPneumothorax* GetRightClosedTensionPneumothorax(); + SETensionPneumothorax& GetRightClosedTensionPneumothorax(); const SETensionPneumothorax* GetRightClosedTensionPneumothorax() const; void RemoveRightClosedTensionPneumothorax(); bool HasRightOpenTensionPneumothorax() const; - SETensionPneumothorax* GetRightOpenTensionPneumothorax(); + SETensionPneumothorax& GetRightOpenTensionPneumothorax(); const SETensionPneumothorax* GetRightOpenTensionPneumothorax() const; void RemoveRightOpenTensionPneumothorax(); bool HasUrinate() const; - SEUrinate* GetUrinate(); + SEUrinate& GetUrinate(); const SEUrinate* GetUrinate() const; void RemoveUrinate(); void GetAllActions(std::vector& v) const; + const SEScalar* GetScalar(const std::string& actionName, const std::string& cmptName, const std::string& substance, const std::string& property); protected: void Clear(); - bool ProcessAction(const SEPatientAction& action, SESubstanceManager&); + bool ProcessAction(const SEPatientAction& action); + + SESubstanceManager& m_SubMgr; SEAcuteRespiratoryDistressSyndromeExacerbation* m_ARDSExacerbation; SEAcuteStress* m_AcuteStress; @@ -232,7 +255,8 @@ protected: SEBrainInjury* m_BrainInjury; SEBronchoconstriction* m_Bronchoconstriction; SECardiacArrest* m_CardiacArrest; - SEChestCompression* m_ChestCompression; + SEChestCompressionForce* m_ChestCompressionForce; + SEChestCompressionForceScale* m_ChestCompressionForceScale; SEChestOcclusiveDressing* m_LeftChestOcclusiveDressing; SEChestOcclusiveDressing* m_RightChestOcclusiveDressing; SEConsciousRespiration* m_ConsciousRespiration; @@ -256,8 +280,8 @@ protected: SETensionPneumothorax* m_RightOpenTensionPneumothorax; SEUrinate* m_Urinate; - std::map m_Hemorrhages; - std::map m_SubstanceBolus; - std::map m_SubstanceInfusions; - std::map m_SubstanceCompoundInfusions; + std::vector m_Hemorrhages; + std::vector m_SubstanceBoluses; + std::vector m_SubstanceInfusions; + std::vector m_SubstanceCompoundInfusions; }; diff --git a/src/cpp/cdm/engine/SESerializeState.cpp b/src/cpp/cdm/engine/SESerializeState.cpp index f03c4d28c19e8f617d750bc3fc573a3e4878bafc..fbbe5d69dca18f24e5eefdc9ee8e1786fb380dc2 100644 --- a/src/cpp/cdm/engine/SESerializeState.cpp +++ b/src/cpp/cdm/engine/SESerializeState.cpp @@ -27,14 +27,6 @@ bool SESerializeState::IsValid() const return HasFilename(); } -void SESerializeState::ToString(std::ostream &str) const -{ - if(HasComment()) - str<<"\n\tComment : "<AddAllocated(PBCondition::Unload(*src.m_InitialEnvironmentalConditions)); } -void PBEngine::Load(const CDM_BIND::ActionListData& src, SEActionManager& dst, SESubstanceManager& subMgr) +void PBEngine::Load(const CDM_BIND::ActionListData& src, SEActionManager& dst) { dst.Clear(); - PBEngine::Serialize(src, dst, subMgr); + PBEngine::Serialize(src, dst); } -void PBEngine::Serialize(const CDM_BIND::ActionListData& src, SEActionManager& dst, SESubstanceManager& subMgr) +void PBEngine::Serialize(const CDM_BIND::ActionListData& src, SEActionManager& dst) { for (int i = 0; i < src.anyaction_size(); i++) { - SEAction* a = PBAction::Load(src.anyaction()[i], subMgr); - dst.ProcessAction(*a, subMgr); + SEAction* a = PBAction::Load(src.anyaction()[i], dst.m_SubMgr); + dst.ProcessAction(*a); delete a; } } @@ -290,8 +290,10 @@ void PBEngine::Serialize(const SEPatientActionCollection& src, CDM_BIND::ActionL dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*src.m_Bronchoconstriction)); if (src.HasCardiacArrest()) dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*src.m_CardiacArrest)); - if (src.HasChestCompression()) - dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*src.m_ChestCompression)); + if (src.HasChestCompressionForce()) + dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*src.m_ChestCompressionForce)); + else if (src.HasChestCompressionForceScale()) + dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*src.m_ChestCompressionForceScale)); if (src.HasLeftChestOcclusiveDressing()) dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*src.m_LeftChestOcclusiveDressing)); if (src.HasRightChestOcclusiveDressing()) @@ -308,8 +310,11 @@ void PBEngine::Serialize(const SEPatientActionCollection& src, CDM_BIND::ActionL dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*src.m_Exercise)); if (src.HasHemorrhage()) { - for (auto itr : src.m_Hemorrhages) - dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*itr.second)); + for (auto h : src.m_Hemorrhages) + { + if(h->IsActive()) + dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*h)); + } } if (src.HasImpairedAlveolarExchangeExacerbation()) dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*src.m_ImpairedAlveolarExchangeExacerbation)); @@ -337,12 +342,21 @@ void PBEngine::Serialize(const SEPatientActionCollection& src, CDM_BIND::ActionL dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*src.m_RightClosedTensionPneumothorax)); if (src.GetRightOpenTensionPneumothorax()) dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*src.m_RightOpenTensionPneumothorax)); - for (auto itr : src.m_SubstanceBolus) - dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*itr.second)); - for (auto itr : src.m_SubstanceInfusions) - dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*itr.second)); - for (auto itr : src.m_SubstanceCompoundInfusions) - dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*itr.second)); + for (auto b : src.m_SubstanceBoluses) + { + if(b->IsActive()) + dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*b)); + } + for (auto i : src.m_SubstanceInfusions) + { + if(i->IsActive()) + dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*i)); + } + for (auto ci : src.m_SubstanceCompoundInfusions) + { + if(ci->IsActive()) + dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*ci)); + } if (src.HasUrinate()) dst.mutable_anyaction()->AddAllocated(PBAction::Unload(*src.m_Urinate)); } @@ -434,6 +448,7 @@ void PBEngine::Serialize(const CDM_BIND::DataRequestData& src, SEDataRequest& ds { if(src.has_decimalformat()) PBEngine::Serialize(src.decimalformat(), dst); + dst.m_ActionName = src.actionname(); dst.m_CompartmentName = src.compartmentname(); dst.m_SubstanceName = src.substancename(); dst.m_PropertyName = src.propertyname(); @@ -449,6 +464,8 @@ void PBEngine::Serialize(const SEDataRequest& src, CDM_BIND::DataRequestData& ds { PBEngine::Serialize(src, *dst.mutable_decimalformat()); dst.set_category((CDM_BIND::DataRequestData::eCategory)src.m_Category); + if (src.HasActionName()) + dst.set_actionname(src.m_ActionName); if (src.HasCompartmentName()) dst.set_compartmentname(src.m_CompartmentName); if (src.HasSubstanceName()) @@ -581,20 +598,20 @@ bool PBEngine::SerializeToFile(const SEActionManager& src, const std::string& fi PBEngine::Serialize(src, data); return PBUtils::SerializeToFile(data, filename, src.GetLogger()); } -bool PBEngine::SerializeFromString(const std::string& src, SEActionManager& dst, SerializationFormat m, SESubstanceManager& subMgr) +bool PBEngine::SerializeFromString(const std::string& src, SEActionManager& dst, SerializationFormat m) { CDM_BIND::ActionListData data; if (!PBUtils::SerializeFromString(src, data, m, dst.GetLogger())) return false; - PBEngine::Load(data, dst, subMgr); + PBEngine::Load(data, dst); return true; } -bool PBEngine::SerializeFromFile(const std::string& filename, SEActionManager& dst, SESubstanceManager& subMgr) +bool PBEngine::SerializeFromFile(const std::string& filename, SEActionManager& dst) { CDM_BIND::ActionListData data; if (!PBUtils::SerializeFromFile(filename, data, dst.GetLogger())) return false; - PBEngine::Load(data, dst, subMgr); + PBEngine::Load(data, dst); return true; } diff --git a/src/cpp/cdm/io/protobuf/PBEngine.h b/src/cpp/cdm/io/protobuf/PBEngine.h index 50399efa2fcc5db00eff78c00e69129e1111c162..3f0d9018df1c1a85cb8b68b8df6b47460ae98d7b 100644 --- a/src/cpp/cdm/io/protobuf/PBEngine.h +++ b/src/cpp/cdm/io/protobuf/PBEngine.h @@ -52,9 +52,9 @@ public: static bool SerializeFromString(const std::string& src, SEConditionManager& dst, SerializationFormat m, const SESubstanceManager& subMgr); static bool SerializeFromFile(const std::string& filename, SEConditionManager& dst, const SESubstanceManager& subMgr); - static void Load(const CDM_BIND::ActionListData& src, SEActionManager& dst, SESubstanceManager& subMgr); + static void Load(const CDM_BIND::ActionListData& src, SEActionManager& dst); static CDM_BIND::ActionListData* Unload(const SEActionManager& src); - static void Serialize(const CDM_BIND::ActionListData& src, SEActionManager& dst, SESubstanceManager& subMgr); + static void Serialize(const CDM_BIND::ActionListData& src, SEActionManager& dst); static void Serialize(const SEActionManager& src, CDM_BIND::ActionListData& dst); static void Serialize(const SEEquipmentActionCollection& src, CDM_BIND::ActionListData& dst); static void Serialize(const SEEnvironmentActionCollection& src, CDM_BIND::ActionListData& dst); @@ -62,8 +62,8 @@ public: static bool SerializeToString(const SEActionManager& src, std::string& output, SerializationFormat m); static bool SerializeToFile(const SEActionManager& src, const std::string& filename); - static bool SerializeFromString(const std::string& src, SEActionManager& dst, SerializationFormat m, SESubstanceManager& subMgr); - static bool SerializeFromFile(const std::string& filename, SEActionManager& dst, SESubstanceManager& subMgr); + static bool SerializeFromString(const std::string& src, SEActionManager& dst, SerializationFormat m); + static bool SerializeFromFile(const std::string& filename, SEActionManager& dst); static void Load(const CDM_BIND::ActionListData& src, std::vector& dst, const SESubstanceManager& subMgr); static void Serialize(const CDM_BIND::ActionListData& src, std::vector& dst, const SESubstanceManager& subMgr); diff --git a/src/cpp/cdm/io/protobuf/PBEquipmentActions.cpp b/src/cpp/cdm/io/protobuf/PBEquipmentActions.cpp index ecc69990de98d58d17eb6fa58358f9b858d785a9..7e17985fbb613f2efef9aa8f7540e79f49883f69 100644 --- a/src/cpp/cdm/io/protobuf/PBEquipmentActions.cpp +++ b/src/cpp/cdm/io/protobuf/PBEquipmentActions.cpp @@ -250,7 +250,7 @@ void PBEquipmentAction::Load(const CDM_BIND::AnesthesiaMachineOxygenTankPressure void PBEquipmentAction::Serialize(const CDM_BIND::AnesthesiaMachineOxygenTankPressureLossData& src, SEAnesthesiaMachineOxygenTankPressureLoss& dst) { PBEquipmentAction::Serialize(src.anesthesiamachineaction(), dst); - dst.SetActive(src.state() == CDM_BIND::eSwitch::On ? true : false); + dst.SetState(src.state() == CDM_BIND::eSwitch::On ? eSwitch::On : eSwitch::Off); } CDM_BIND::AnesthesiaMachineOxygenTankPressureLossData* PBEquipmentAction::Unload(const SEAnesthesiaMachineOxygenTankPressureLoss& src) { @@ -261,7 +261,7 @@ CDM_BIND::AnesthesiaMachineOxygenTankPressureLossData* PBEquipmentAction::Unload void PBEquipmentAction::Serialize(const SEAnesthesiaMachineOxygenTankPressureLoss& src, CDM_BIND::AnesthesiaMachineOxygenTankPressureLossData& dst) { PBEquipmentAction::Serialize(src, *dst.mutable_anesthesiamachineaction()); - dst.set_state(src.IsActive() ? CDM_BIND::eSwitch::On : CDM_BIND::eSwitch::Off); + dst.set_state(src.GetState()==eSwitch::On ? CDM_BIND::eSwitch::On : CDM_BIND::eSwitch::Off); } void PBEquipmentAction::Copy(const SEAnesthesiaMachineOxygenTankPressureLoss& src, SEAnesthesiaMachineOxygenTankPressureLoss& dst) { @@ -279,7 +279,7 @@ void PBEquipmentAction::Load(const CDM_BIND::AnesthesiaMachineOxygenWallPortPres void PBEquipmentAction::Serialize(const CDM_BIND::AnesthesiaMachineOxygenWallPortPressureLossData& src, SEAnesthesiaMachineOxygenWallPortPressureLoss& dst) { PBEquipmentAction::Serialize(src.anesthesiamachineaction(), dst); - dst.SetActive(src.state() == CDM_BIND::eSwitch::On ? true : false); + dst.SetState(src.state() == CDM_BIND::eSwitch::On ? eSwitch::On : eSwitch::Off); } CDM_BIND::AnesthesiaMachineOxygenWallPortPressureLossData* PBEquipmentAction::Unload(const SEAnesthesiaMachineOxygenWallPortPressureLoss& src) { @@ -290,7 +290,7 @@ CDM_BIND::AnesthesiaMachineOxygenWallPortPressureLossData* PBEquipmentAction::Un void PBEquipmentAction::Serialize(const SEAnesthesiaMachineOxygenWallPortPressureLoss& src, CDM_BIND::AnesthesiaMachineOxygenWallPortPressureLossData& dst) { PBEquipmentAction::Serialize(src, *dst.mutable_anesthesiamachineaction()); - dst.set_state(src.IsActive() ? CDM_BIND::eSwitch::On : CDM_BIND::eSwitch::Off); + dst.set_state(src.GetState()==eSwitch::On ? CDM_BIND::eSwitch::On : CDM_BIND::eSwitch::Off); } void PBEquipmentAction::Copy(const SEAnesthesiaMachineOxygenWallPortPressureLoss& src, SEAnesthesiaMachineOxygenWallPortPressureLoss& dst) { diff --git a/src/cpp/cdm/io/protobuf/PBPatientActions.cpp b/src/cpp/cdm/io/protobuf/PBPatientActions.cpp index 7e2d5ab81040fc70b32a9ec446251d6e61a10d1a..c3d113ff3b25ec5210362ff4d8b7fc5e905a34d9 100644 --- a/src/cpp/cdm/io/protobuf/PBPatientActions.cpp +++ b/src/cpp/cdm/io/protobuf/PBPatientActions.cpp @@ -723,6 +723,8 @@ void PBPatientAction::Serialize(const CDM_BIND::HemorrhageData& src, SEHemorrhag PBProperty::Load(src.flowrate(), dst.GetFlowRate()); if (src.has_severity()) PBProperty::Load(src.severity(), dst.GetSeverity()); + if (src.has_totalbloodlost()) + PBProperty::Load(src.totalbloodlost(), dst.GetTotalBloodLost()); } CDM_BIND::HemorrhageData* PBPatientAction::Unload(const SEHemorrhage& src) { @@ -740,6 +742,8 @@ void PBPatientAction::Serialize(const SEHemorrhage& src, CDM_BIND::HemorrhageDat dst.set_allocated_flowrate(PBProperty::Unload(*src.m_FlowRate)); if (src.HasSeverity()) dst.set_allocated_severity(PBProperty::Unload(*src.m_Severity)); + if (src.HasTotalBloodLost()) + dst.set_allocated_totalbloodlost(PBProperty::Unload(*src.m_TotalBloodLost)); } void PBPatientAction::Copy(const SEHemorrhage& src, SEHemorrhage& dst) { @@ -1105,8 +1109,6 @@ void PBPatientAction::Serialize(const CDM_BIND::SubstanceBolusData& src, SESubst PBProperty::Load(src.dose(), dst.GetDose()); if (src.has_concentration()) PBProperty::Load(src.concentration(), dst.GetConcentration()); - if (src.has_state()) - PBPatientAction::Load(src.state(), dst.m_State); } CDM_BIND::SubstanceBolusData* PBPatientAction::Unload(const SESubstanceBolus& src) { @@ -1125,7 +1127,6 @@ void PBPatientAction::Serialize(const SESubstanceBolus& src, CDM_BIND::Substance dst.set_allocated_dose(PBProperty::Unload(*src.m_Dose)); if (src.HasConcentration()) dst.set_allocated_concentration(PBProperty::Unload(*src.m_Concentration)); - dst.set_allocated_state(PBPatientAction::Unload(src.m_State)); } void PBPatientAction::Copy(const SESubstanceBolus& src, SESubstanceBolus& dst) { @@ -1135,38 +1136,6 @@ void PBPatientAction::Copy(const SESubstanceBolus& src, SESubstanceBolus& dst) PBPatientAction::Serialize(data, dst); } -void PBPatientAction::Load(const CDM_BIND::SubstanceBolusStateData& src, SESubstanceBolusState& dst) -{ - dst.Clear(); - PBPatientAction::Serialize(src, dst); -} -void PBPatientAction::Serialize(const CDM_BIND::SubstanceBolusStateData& src, SESubstanceBolusState& dst) -{ - if (src.has_elapsedtime()) - PBProperty::Load(src.elapsedtime(), dst.GetElapsedTime()); - if (src.has_administereddose()) - PBProperty::Load(src.administereddose(), dst.GetAdministeredDose()); -} -CDM_BIND::SubstanceBolusStateData* PBPatientAction::Unload(const SESubstanceBolusState& src) -{ - CDM_BIND::SubstanceBolusStateData* dst = new CDM_BIND::SubstanceBolusStateData(); - PBPatientAction::Serialize(src, *dst); - return dst; -} -void PBPatientAction::Serialize(const SESubstanceBolusState& src, CDM_BIND::SubstanceBolusStateData& dst) -{ - dst.set_substance(src.m_Substance.GetName()); - dst.set_allocated_elapsedtime(PBProperty::Unload(*src.m_ElapsedTime)); - dst.set_allocated_administereddose(PBProperty::Unload(*src.m_AdministeredDose)); -} -void PBPatientAction::Copy(const SESubstanceBolusState& src, SESubstanceBolusState& dst) -{ - dst.Clear(); - CDM_BIND::SubstanceBolusStateData data; - PBPatientAction::Serialize(src, data); - PBPatientAction::Serialize(data, dst); -} - void PBPatientAction::Load(const CDM_BIND::SubstanceCompoundInfusionData& src, SESubstanceCompoundInfusion& dst) { dst.Clear(); diff --git a/src/cpp/cdm/io/protobuf/PBSubstance.cpp b/src/cpp/cdm/io/protobuf/PBSubstance.cpp index c9081549e0e1b8e9c6f70d1ce0f810f0ef90b756..ecee18bb2d7e5fee186fb4466cd672fffe0692ce 100644 --- a/src/cpp/cdm/io/protobuf/PBSubstance.cpp +++ b/src/cpp/cdm/io/protobuf/PBSubstance.cpp @@ -328,7 +328,6 @@ void PBSubstance::Serialize(const CDM_BIND::SubstanceCompoundData& src, SESubsta std::string err; const SESubstance* substance = nullptr; - SESubstanceConcentration* cc; for (int i = 0; i < src.component_size(); i++) { const CDM_BIND::SubstanceConcentrationData& cData = src.component(i); @@ -339,10 +338,8 @@ void PBSubstance::Serialize(const CDM_BIND::SubstanceCompoundData& src, SESubsta dst.Fatal("Could not load find substance compound component : " + cData.name(), "SESubstanceCompound::Load"); continue; } - cc = new SESubstanceConcentration(*substance); - PBSubstance::Load(cData, *cc); - dst.m_Components.push_back(cc); - dst.m_cComponents.push_back(cc); + SESubstanceConcentration& sc = dst.GetComponent(*substance); + PBSubstance::Load(cData, sc); } } diff --git a/src/cpp/cdm/patient/actions/SEAcuteRespiratoryDistressSyndromeExacerbation.cpp b/src/cpp/cdm/patient/actions/SEAcuteRespiratoryDistressSyndromeExacerbation.cpp index c047dd50d7071588dbd31d52c255479ab36cdaa4..a6bdf423868d9ea6771af83812fab1d91ceb0ab7 100644 --- a/src/cpp/cdm/patient/actions/SEAcuteRespiratoryDistressSyndromeExacerbation.cpp +++ b/src/cpp/cdm/patient/actions/SEAcuteRespiratoryDistressSyndromeExacerbation.cpp @@ -28,18 +28,22 @@ void SEAcuteRespiratoryDistressSyndromeExacerbation::Clear() INVALIDATE_PROPERTY(m_RightLungAffected); } -void SEAcuteRespiratoryDistressSyndromeExacerbation::Copy(const SEAcuteRespiratoryDistressSyndromeExacerbation& src) +void SEAcuteRespiratoryDistressSyndromeExacerbation::Copy(const SEAcuteRespiratoryDistressSyndromeExacerbation& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEAcuteRespiratoryDistressSyndromeExacerbation::IsValid() const { + if (!SEPatientAction::IsValid()) + return false; return HasSeverity() && HasLeftLungAffected() && HasRightLungAffected(); } bool SEAcuteRespiratoryDistressSyndromeExacerbation::IsActive() const { - if (!IsValid()) + if (!SEPatientAction::IsActive()) return false; if (GetSeverity() <= 0) return false; @@ -47,6 +51,22 @@ bool SEAcuteRespiratoryDistressSyndromeExacerbation::IsActive() const return false; return true; } +void SEAcuteRespiratoryDistressSyndromeExacerbation::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAcuteRespiratoryDistressSyndromeExacerbation::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + if (name.compare("LeftLungAffected") == 0) + return &GetLeftLungAffected(); + if (name.compare("RightLungAffected") == 0) + return &GetRightLungAffected(); + return nullptr; +} bool SEAcuteRespiratoryDistressSyndromeExacerbation::HasSeverity() const { diff --git a/src/cpp/cdm/patient/actions/SEAcuteRespiratoryDistressSyndromeExacerbation.h b/src/cpp/cdm/patient/actions/SEAcuteRespiratoryDistressSyndromeExacerbation.h index 6aeb168025690c594882b4333a7f8122e352a08e..71fc2a01857e4e8f2a46e84f24e215d91d6331ba 100644 --- a/src/cpp/cdm/patient/actions/SEAcuteRespiratoryDistressSyndromeExacerbation.h +++ b/src/cpp/cdm/patient/actions/SEAcuteRespiratoryDistressSyndromeExacerbation.h @@ -13,10 +13,11 @@ public: virtual ~SEAcuteRespiratoryDistressSyndromeExacerbation(); virtual void Clear(); //clear memory - virtual void Copy(const SEAcuteRespiratoryDistressSyndromeExacerbation& src); + virtual void Copy(const SEAcuteRespiratoryDistressSyndromeExacerbation& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -32,6 +33,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; SEScalar0To1* m_LeftLungAffected; diff --git a/src/cpp/cdm/patient/actions/SEAcuteStress.cpp b/src/cpp/cdm/patient/actions/SEAcuteStress.cpp index 58e95cc2d371a916d73bb383833061a4072cb824..ef4aae0e9c8fd124e3699413cee66a17e018ef86 100644 --- a/src/cpp/cdm/patient/actions/SEAcuteStress.cpp +++ b/src/cpp/cdm/patient/actions/SEAcuteStress.cpp @@ -22,9 +22,11 @@ void SEAcuteStress::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAcuteStress::Copy(const SEAcuteStress& src) +void SEAcuteStress::Copy(const SEAcuteStress& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEAcuteStress::IsValid() const @@ -34,7 +36,21 @@ bool SEAcuteStress::IsValid() const bool SEAcuteStress::IsActive() const { - return IsValid() ? !m_Severity->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_Severity->IsZero(); +} +void SEAcuteStress::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAcuteStress::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; } bool SEAcuteStress::HasSeverity() const diff --git a/src/cpp/cdm/patient/actions/SEAcuteStress.h b/src/cpp/cdm/patient/actions/SEAcuteStress.h index 63619490943576957987fb8b8ef3252a846f20f7..df9b2d3a1c35d412d21f9e559a2fef9ef927e803 100644 --- a/src/cpp/cdm/patient/actions/SEAcuteStress.h +++ b/src/cpp/cdm/patient/actions/SEAcuteStress.h @@ -13,10 +13,11 @@ public: virtual ~SEAcuteStress(); virtual void Clear(); - virtual void Copy(const SEAcuteStress& src); + virtual void Copy(const SEAcuteStress& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -24,6 +25,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; }; diff --git a/src/cpp/cdm/patient/actions/SEAirwayObstruction.cpp b/src/cpp/cdm/patient/actions/SEAirwayObstruction.cpp index 0ba253c7f3bfbab6d6019838bd4099e09e15df51..0318373f24e5274409416d0f4cde61c8d7f62e8a 100644 --- a/src/cpp/cdm/patient/actions/SEAirwayObstruction.cpp +++ b/src/cpp/cdm/patient/actions/SEAirwayObstruction.cpp @@ -22,9 +22,11 @@ void SEAirwayObstruction::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAirwayObstruction::Copy(const SEAirwayObstruction& src) +void SEAirwayObstruction::Copy(const SEAirwayObstruction& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEAirwayObstruction::IsValid() const @@ -34,7 +36,21 @@ bool SEAirwayObstruction::IsValid() const bool SEAirwayObstruction::IsActive() const { - return IsValid() ? !m_Severity->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_Severity->IsZero(); +} +void SEAirwayObstruction::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAirwayObstruction::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; } bool SEAirwayObstruction::HasSeverity() const diff --git a/src/cpp/cdm/patient/actions/SEAirwayObstruction.h b/src/cpp/cdm/patient/actions/SEAirwayObstruction.h index cd1f2be5de1905558ff60242f5d7cef39a34da30..75f6c9789e9652889f895859226a74575ec19344 100644 --- a/src/cpp/cdm/patient/actions/SEAirwayObstruction.h +++ b/src/cpp/cdm/patient/actions/SEAirwayObstruction.h @@ -13,10 +13,11 @@ public: virtual ~SEAirwayObstruction(); virtual void Clear(); - virtual void Copy(const SEAirwayObstruction& src); + virtual void Copy(const SEAirwayObstruction& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -24,6 +25,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; }; \ No newline at end of file diff --git a/src/cpp/cdm/patient/actions/SEAsthmaAttack.cpp b/src/cpp/cdm/patient/actions/SEAsthmaAttack.cpp index af42bfd023e4f91cdf84f5f267acddf3d5750f77..1f526ff7324747795c77b41e1b7f4a339372ff6c 100644 --- a/src/cpp/cdm/patient/actions/SEAsthmaAttack.cpp +++ b/src/cpp/cdm/patient/actions/SEAsthmaAttack.cpp @@ -22,9 +22,11 @@ void SEAsthmaAttack::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAsthmaAttack::Copy(const SEAsthmaAttack& src) +void SEAsthmaAttack::Copy(const SEAsthmaAttack& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEAsthmaAttack::IsValid() const @@ -34,7 +36,21 @@ bool SEAsthmaAttack::IsValid() const bool SEAsthmaAttack::IsActive() const { - return IsValid() ? !m_Severity->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_Severity->IsZero(); +} +void SEAsthmaAttack::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAsthmaAttack::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; } bool SEAsthmaAttack::HasSeverity() const diff --git a/src/cpp/cdm/patient/actions/SEAsthmaAttack.h b/src/cpp/cdm/patient/actions/SEAsthmaAttack.h index a6d56eaaf66f9ec9271bd3b7e017f9cfbf22142f..f3d50b57de8463a74d39354b1039c792495c1cbb 100644 --- a/src/cpp/cdm/patient/actions/SEAsthmaAttack.h +++ b/src/cpp/cdm/patient/actions/SEAsthmaAttack.h @@ -13,10 +13,11 @@ public: virtual ~SEAsthmaAttack(); virtual void Clear(); //clear memory - virtual void Copy(const SEAsthmaAttack& src); + virtual void Copy(const SEAsthmaAttack& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -24,6 +25,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; }; diff --git a/src/cpp/cdm/patient/actions/SEBrainInjury.cpp b/src/cpp/cdm/patient/actions/SEBrainInjury.cpp index aeff7bf8da10db9d5cec0623fcb1e19b7b13786b..d4f2d4fd72a1b7b0b6906b9322d7c0647ad5c0de 100644 --- a/src/cpp/cdm/patient/actions/SEBrainInjury.cpp +++ b/src/cpp/cdm/patient/actions/SEBrainInjury.cpp @@ -25,9 +25,11 @@ void SEBrainInjury::Clear() m_Type = eBrainInjury_Type::Diffuse; } -void SEBrainInjury::Copy(const SEBrainInjury& src) +void SEBrainInjury::Copy(const SEBrainInjury& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEBrainInjury::IsValid() const @@ -37,7 +39,21 @@ bool SEBrainInjury::IsValid() const bool SEBrainInjury::IsActive() const { - return IsValid() ? !m_Severity->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_Severity->IsZero(); +} +void SEBrainInjury::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEBrainInjury::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; } bool SEBrainInjury::HasSeverity() const diff --git a/src/cpp/cdm/patient/actions/SEBrainInjury.h b/src/cpp/cdm/patient/actions/SEBrainInjury.h index bc76c89126b556884bb3ae2f8b54797d4e05018d..4c9b324871cc5fbae38ef1aa77b55528ef983d2d 100644 --- a/src/cpp/cdm/patient/actions/SEBrainInjury.h +++ b/src/cpp/cdm/patient/actions/SEBrainInjury.h @@ -17,10 +17,11 @@ public: virtual ~SEBrainInjury(); virtual void Clear(); - virtual void Copy(const SEBrainInjury& src); + virtual void Copy(const SEBrainInjury& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -31,6 +32,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; eBrainInjury_Type m_Type; diff --git a/src/cpp/cdm/patient/actions/SEBronchoconstriction.cpp b/src/cpp/cdm/patient/actions/SEBronchoconstriction.cpp index 6bf9e1784435f4ad7d656b06fa6b8988206e9f5b..69e3fba0e22122aeaa6c70499a2f00dd7f1a0493 100644 --- a/src/cpp/cdm/patient/actions/SEBronchoconstriction.cpp +++ b/src/cpp/cdm/patient/actions/SEBronchoconstriction.cpp @@ -22,9 +22,11 @@ void SEBronchoconstriction::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEBronchoconstriction::Copy(const SEBronchoconstriction& src) +void SEBronchoconstriction::Copy(const SEBronchoconstriction& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEBronchoconstriction::IsValid() const @@ -34,7 +36,21 @@ bool SEBronchoconstriction::IsValid() const bool SEBronchoconstriction::IsActive() const { - return IsValid() ? !m_Severity->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_Severity->IsZero(); +} +void SEBronchoconstriction::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEBronchoconstriction::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; } bool SEBronchoconstriction::HasSeverity() const diff --git a/src/cpp/cdm/patient/actions/SEBronchoconstriction.h b/src/cpp/cdm/patient/actions/SEBronchoconstriction.h index e96d0cd71b4c8999cc1c9d775ab39dedd4bc1f47..58e183be18ca581413523e25cd15b06699b6c59c 100644 --- a/src/cpp/cdm/patient/actions/SEBronchoconstriction.h +++ b/src/cpp/cdm/patient/actions/SEBronchoconstriction.h @@ -13,10 +13,11 @@ public: virtual ~SEBronchoconstriction(); virtual void Clear(); //clear memory - virtual void Copy(const SEBronchoconstriction& src); + virtual void Copy(const SEBronchoconstriction& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -24,6 +25,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; }; diff --git a/src/cpp/cdm/patient/actions/SECardiacArrest.cpp b/src/cpp/cdm/patient/actions/SECardiacArrest.cpp index dc83175ce0d611f39a26d910c924826aab42530a..a46e2cb15ad84e301093afb2c964db7e94fc52ea 100644 --- a/src/cpp/cdm/patient/actions/SECardiacArrest.cpp +++ b/src/cpp/cdm/patient/actions/SECardiacArrest.cpp @@ -21,9 +21,11 @@ void SECardiacArrest::Clear() m_State = eSwitch::Off; } -void SECardiacArrest::Copy(const SECardiacArrest& src) +void SECardiacArrest::Copy(const SECardiacArrest& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SECardiacArrest::IsValid() const @@ -33,7 +35,19 @@ bool SECardiacArrest::IsValid() const bool SECardiacArrest::IsActive() const { - return IsValid() && m_State == eSwitch::On; + if (!SEPatientAction::IsActive()) + return false; + return m_State == eSwitch::On; +} +void SECardiacArrest::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SECardiacArrest::GetScalar(const std::string& name) +{ + return nullptr; } void SECardiacArrest::ToString(std::ostream &str) const diff --git a/src/cpp/cdm/patient/actions/SECardiacArrest.h b/src/cpp/cdm/patient/actions/SECardiacArrest.h index 94b6b97a34449aad0410d4ce41be762b9ddc5f3d..f103bd3b64b67764e8f647c4533f644ce37fc074 100644 --- a/src/cpp/cdm/patient/actions/SECardiacArrest.h +++ b/src/cpp/cdm/patient/actions/SECardiacArrest.h @@ -13,16 +13,19 @@ public: virtual ~SECardiacArrest(); virtual void Clear(); //clear memory - virtual void Copy(const SECardiacArrest& src); + virtual void Copy(const SECardiacArrest& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual eSwitch GetState() const { return m_State; } virtual void SetState(eSwitch s) { m_State = (s == eSwitch::NullSwitch) ? eSwitch::Off : s; } virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: eSwitch m_State; diff --git a/src/cpp/cdm/patient/actions/SEChestCompression.cpp b/src/cpp/cdm/patient/actions/SEChestCompression.cpp deleted file mode 100644 index 6a7d6772144dc16fb307d04e2d5560e1da18fcdc..0000000000000000000000000000000000000000 --- a/src/cpp/cdm/patient/actions/SEChestCompression.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* Distributed under the Apache License, Version 2.0. - See accompanying NOTICE file for details.*/ - -#include "stdafx.h" -#include "patient/actions/SEChestCompression.h" -#include "io/protobuf/PBPatientActions.h" - -SEChestCompression::SEChestCompression(Logger* logger) : SEPatientAction(logger) -{ - -} - -SEChestCompression::~SEChestCompression() -{ - Clear(); -} - -void SEChestCompression::Clear() -{ - SEPatientAction::Clear(); -} - -bool SEChestCompression::IsValid() const -{ - return SEPatientAction::IsValid(); -} - -bool SEChestCompression::IsActive() const -{ - return IsValid(); -} diff --git a/src/cpp/cdm/patient/actions/SEChestCompression.h b/src/cpp/cdm/patient/actions/SEChestCompression.h deleted file mode 100644 index 626685f9033906a5cdcfe0be5bf5843c1db70848..0000000000000000000000000000000000000000 --- a/src/cpp/cdm/patient/actions/SEChestCompression.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Distributed under the Apache License, Version 2.0. - See accompanying NOTICE file for details.*/ - -#pragma once -#include "patient/actions/SEPatientAction.h" - -class CDM_DECL SEChestCompression : public SEPatientAction -{ - friend class PBPatientAction;//friend the serialization class -public: - - SEChestCompression(Logger* logger); - virtual ~SEChestCompression(); - - virtual void Clear(); //clear memory - - virtual bool IsValid() const; - virtual bool IsActive() const; - -public: - - virtual void ToString(std::ostream &str) const = 0; -protected: -}; \ No newline at end of file diff --git a/src/cpp/cdm/patient/actions/SEChestCompressionForce.cpp b/src/cpp/cdm/patient/actions/SEChestCompressionForce.cpp index e41e91b605843443f72651ca7ce02a790a625b3b..f0806a6354c8ceb1c939fcda8d8bb3ea1ad00b90 100644 --- a/src/cpp/cdm/patient/actions/SEChestCompressionForce.cpp +++ b/src/cpp/cdm/patient/actions/SEChestCompressionForce.cpp @@ -6,7 +6,7 @@ #include "properties/SEScalarForce.h" #include "io/protobuf/PBPatientActions.h" -SEChestCompressionForce::SEChestCompressionForce(Logger* logger) : SEChestCompression(logger) +SEChestCompressionForce::SEChestCompressionForce(Logger* logger) : SEPatientAction(logger) { m_Force = nullptr; } @@ -18,23 +18,39 @@ SEChestCompressionForce::~SEChestCompressionForce() void SEChestCompressionForce::Clear() { - SEChestCompression::Clear(); + SEPatientAction::Clear(); INVALIDATE_PROPERTY(m_Force); } -void SEChestCompressionForce::Copy(const SEChestCompressionForce& src) +void SEChestCompressionForce::Copy(const SEChestCompressionForce& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEChestCompressionForce::IsValid() const { - return SEChestCompression::IsValid() && HasForce(); + return SEPatientAction::IsValid() && HasForce(); } bool SEChestCompressionForce::IsActive() const { - return IsValid() ? !m_Force->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_Force->IsZero(); +} +void SEChestCompressionForce::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEChestCompressionForce::GetScalar(const std::string& name) +{ + if (name.compare("Force") == 0) + return &GetForce(); + return nullptr; } bool SEChestCompressionForce::HasForce() const diff --git a/src/cpp/cdm/patient/actions/SEChestCompressionForce.h b/src/cpp/cdm/patient/actions/SEChestCompressionForce.h index 435694a29c44d900b402fa71f7688ca24abea63f..e8c16bd2c446985382c4d295c76ac7429b88ae3b 100644 --- a/src/cpp/cdm/patient/actions/SEChestCompressionForce.h +++ b/src/cpp/cdm/patient/actions/SEChestCompressionForce.h @@ -2,9 +2,9 @@ See accompanying NOTICE file for details.*/ #pragma once -#include "patient/actions/SEChestCompression.h" +#include "patient/actions/SEPatientAction.h" -class CDM_DECL SEChestCompressionForce : public SEChestCompression +class CDM_DECL SEChestCompressionForce : public SEPatientAction { friend class PBPatientAction;//friend the serialization class public: @@ -13,10 +13,11 @@ public: virtual ~SEChestCompressionForce(); virtual void Clear(); //clear memory - virtual void Copy(const SEChestCompressionForce& src); + virtual void Copy(const SEChestCompressionForce& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasForce() const; virtual SEScalarForce& GetForce(); @@ -24,6 +25,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalarForce* m_Force; }; \ No newline at end of file diff --git a/src/cpp/cdm/patient/actions/SEChestCompressionForceScale.cpp b/src/cpp/cdm/patient/actions/SEChestCompressionForceScale.cpp index feb02d66f6c392f70127d7c66229003a08dbf6cf..d5d5bdca04644aea31bacab7de279c3b2f1988c8 100644 --- a/src/cpp/cdm/patient/actions/SEChestCompressionForceScale.cpp +++ b/src/cpp/cdm/patient/actions/SEChestCompressionForceScale.cpp @@ -7,7 +7,7 @@ #include "properties/SEScalarTime.h" #include "io/protobuf/PBPatientActions.h" -SEChestCompressionForceScale::SEChestCompressionForceScale(Logger* logger) : SEChestCompression(logger) +SEChestCompressionForceScale::SEChestCompressionForceScale(Logger* logger) : SEPatientAction(logger) { m_ForceScale = nullptr; m_ForcePeriod = nullptr; @@ -21,24 +21,42 @@ SEChestCompressionForceScale::~SEChestCompressionForceScale() void SEChestCompressionForceScale::Clear() { - SEChestCompression::Clear(); + SEPatientAction::Clear(); INVALIDATE_PROPERTY(m_ForceScale); INVALIDATE_PROPERTY(m_ForcePeriod); } -void SEChestCompressionForceScale::Copy(const SEChestCompressionForceScale& src) +void SEChestCompressionForceScale::Copy(const SEChestCompressionForceScale& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEChestCompressionForceScale::IsValid() const { - return SEChestCompression::IsValid() && HasForceScale(); + return SEPatientAction::IsValid() && HasForceScale(); } bool SEChestCompressionForceScale::IsActive() const { - return IsValid() ? !m_ForceScale->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_ForceScale->IsZero(); +} +void SEChestCompressionForceScale::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEChestCompressionForceScale::GetScalar(const std::string& name) +{ + if (name.compare("ForceScale") == 0) + return &GetForceScale(); + if (name.compare("ForcePeriod") == 0) + return &GetForcePeriod(); + return nullptr; } bool SEChestCompressionForceScale::HasForceScale() const diff --git a/src/cpp/cdm/patient/actions/SEChestCompressionForceScale.h b/src/cpp/cdm/patient/actions/SEChestCompressionForceScale.h index 30962cf2edc2f70f9f6dba2e05dd531a93b19051..6a437e067ee4f826cf001afa3aa55a8fe3bf0bb8 100644 --- a/src/cpp/cdm/patient/actions/SEChestCompressionForceScale.h +++ b/src/cpp/cdm/patient/actions/SEChestCompressionForceScale.h @@ -2,9 +2,9 @@ See accompanying NOTICE file for details.*/ #pragma once -#include "patient/actions/SEChestCompression.h" +#include "patient/actions/SEPatientAction.h" -class CDM_DECL SEChestCompressionForceScale : public SEChestCompression +class CDM_DECL SEChestCompressionForceScale : public SEPatientAction { friend class PBPatientAction;//friend the serialization class public: @@ -12,10 +12,11 @@ public: virtual ~SEChestCompressionForceScale(); virtual void Clear(); //clear memory - virtual void Copy(const SEChestCompressionForceScale& src); + virtual void Copy(const SEChestCompressionForceScale& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasForceScale() const; virtual SEScalar0To1& GetForceScale(); @@ -27,6 +28,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_ForceScale; SEScalarTime* m_ForcePeriod; diff --git a/src/cpp/cdm/patient/actions/SEChestOcclusiveDressing.cpp b/src/cpp/cdm/patient/actions/SEChestOcclusiveDressing.cpp index eed652f99375b13ac71ea743ff1be09886ebef14..a40c6234ec5e01b4d8b8ce16ac50dd79ffc1512b 100644 --- a/src/cpp/cdm/patient/actions/SEChestOcclusiveDressing.cpp +++ b/src/cpp/cdm/patient/actions/SEChestOcclusiveDressing.cpp @@ -24,9 +24,11 @@ void SEChestOcclusiveDressing::Clear() m_Side= eSide::NullSide; } -void SEChestOcclusiveDressing::Copy(const SEChestOcclusiveDressing& src) +void SEChestOcclusiveDressing::Copy(const SEChestOcclusiveDressing& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEChestOcclusiveDressing::IsValid() const @@ -36,7 +38,19 @@ bool SEChestOcclusiveDressing::IsValid() const bool SEChestOcclusiveDressing::IsActive() const { - return IsValid() && m_State == eSwitch::On; + if (!SEPatientAction::IsActive()) + return false; + return m_State == eSwitch::On; +} +void SEChestOcclusiveDressing::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEChestOcclusiveDressing::GetScalar(const std::string& name) +{ + return nullptr; } eSide SEChestOcclusiveDressing::GetSide() const diff --git a/src/cpp/cdm/patient/actions/SEChestOcclusiveDressing.h b/src/cpp/cdm/patient/actions/SEChestOcclusiveDressing.h index 28aaf4925fb7efb4acbb5d9524ef6607d95faaf5..09157b15e58b8ed4e86e2662a7a4f82676b04516 100644 --- a/src/cpp/cdm/patient/actions/SEChestOcclusiveDressing.h +++ b/src/cpp/cdm/patient/actions/SEChestOcclusiveDressing.h @@ -13,10 +13,11 @@ public: virtual ~SEChestOcclusiveDressing(); virtual void Clear(); //clear memory - virtual void Copy(const SEChestOcclusiveDressing& src); + virtual void Copy(const SEChestOcclusiveDressing& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual eSwitch GetState() const { return m_State; } virtual void SetState(eSwitch s) { m_State = (s == eSwitch::NullSwitch) ? eSwitch::Off : s; } @@ -28,6 +29,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: eSide m_Side; eSwitch m_State; diff --git a/src/cpp/cdm/patient/actions/SEChronicObstructivePulmonaryDiseaseExacerbation.cpp b/src/cpp/cdm/patient/actions/SEChronicObstructivePulmonaryDiseaseExacerbation.cpp index 002ecbb44d9d657555880b1451368d096ad38cfd..502659f3634d9a5e9774acdb4463ed510425f13a 100644 --- a/src/cpp/cdm/patient/actions/SEChronicObstructivePulmonaryDiseaseExacerbation.cpp +++ b/src/cpp/cdm/patient/actions/SEChronicObstructivePulmonaryDiseaseExacerbation.cpp @@ -25,9 +25,11 @@ void SEChronicObstructivePulmonaryDiseaseExacerbation::Clear() INVALIDATE_PROPERTY(m_EmphysemaSeverity); } -void SEChronicObstructivePulmonaryDiseaseExacerbation::Copy(const SEChronicObstructivePulmonaryDiseaseExacerbation& src) +void SEChronicObstructivePulmonaryDiseaseExacerbation::Copy(const SEChronicObstructivePulmonaryDiseaseExacerbation& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEChronicObstructivePulmonaryDiseaseExacerbation::IsValid() const @@ -37,10 +39,24 @@ bool SEChronicObstructivePulmonaryDiseaseExacerbation::IsValid() const bool SEChronicObstructivePulmonaryDiseaseExacerbation::IsActive() const { - if (!IsValid()) + if (!SEPatientAction::IsActive()) return false; return GetBronchitisSeverity() > 0 || GetEmphysemaSeverity() > 0; } +void SEChronicObstructivePulmonaryDiseaseExacerbation::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEChronicObstructivePulmonaryDiseaseExacerbation::GetScalar(const std::string& name) +{ + if (name.compare("BronchitisSeverity") == 0) + return &GetBronchitisSeverity(); + if (name.compare("EmphysemaSeverity") == 0) + return &GetEmphysemaSeverity(); + return nullptr; +} bool SEChronicObstructivePulmonaryDiseaseExacerbation::HasBronchitisSeverity() const { diff --git a/src/cpp/cdm/patient/actions/SEChronicObstructivePulmonaryDiseaseExacerbation.h b/src/cpp/cdm/patient/actions/SEChronicObstructivePulmonaryDiseaseExacerbation.h index 1432ee6c7410b3b30eedf8788b15311dd846e6c7..ef5f54bc527b22b396c4a8d8cc771370e747bd21 100644 --- a/src/cpp/cdm/patient/actions/SEChronicObstructivePulmonaryDiseaseExacerbation.h +++ b/src/cpp/cdm/patient/actions/SEChronicObstructivePulmonaryDiseaseExacerbation.h @@ -13,10 +13,11 @@ public: virtual ~SEChronicObstructivePulmonaryDiseaseExacerbation(); virtual void Clear(); //clear memory - virtual void Copy(const SEChronicObstructivePulmonaryDiseaseExacerbation& src); + virtual void Copy(const SEChronicObstructivePulmonaryDiseaseExacerbation& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasBronchitisSeverity() const; virtual SEScalar0To1& GetBronchitisSeverity(); @@ -28,6 +29,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_BronchitisSeverity; SEScalar0To1* m_EmphysemaSeverity; diff --git a/src/cpp/cdm/patient/actions/SEConsciousRespiration.cpp b/src/cpp/cdm/patient/actions/SEConsciousRespiration.cpp index 76b3b1be4540900f217329f3a12991a23a8abbbf..63b566790c14afb566732a7c4c45e4aeaefb83c7 100644 --- a/src/cpp/cdm/patient/actions/SEConsciousRespiration.cpp +++ b/src/cpp/cdm/patient/actions/SEConsciousRespiration.cpp @@ -28,10 +28,11 @@ void SEConsciousRespiration::Clear() m_StartImmediately = false; } -void SEConsciousRespiration::Copy(const SEConsciousRespiration& src) +void SEConsciousRespiration::Copy(const SEConsciousRespiration& src, bool preserveState) { - + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEConsciousRespiration::IsValid() const @@ -43,6 +44,16 @@ bool SEConsciousRespiration::IsActive() const { return SEPatientAction::IsActive(); } +void SEConsciousRespiration::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEConsciousRespiration::GetScalar(const std::string& name) +{ + return nullptr; +} bool SEConsciousRespiration::StartImmediately() const { diff --git a/src/cpp/cdm/patient/actions/SEConsciousRespiration.h b/src/cpp/cdm/patient/actions/SEConsciousRespiration.h index 6fda769e8ec4990dfbcc661fbcea15f3fed5a022..c7b9db51cacf4a8a301f3601e18b1c8e46fc8b78 100644 --- a/src/cpp/cdm/patient/actions/SEConsciousRespiration.h +++ b/src/cpp/cdm/patient/actions/SEConsciousRespiration.h @@ -18,10 +18,11 @@ public: virtual ~SEConsciousRespiration(); virtual void Clear(); //clear memory - virtual void Copy(const SEConsciousRespiration& src); + virtual void Copy(const SEConsciousRespiration& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool StartImmediately() const; virtual void SetStartImmediately(bool b); @@ -38,6 +39,9 @@ public: virtual SEUseInhaler& AddUseInhaler(); virtual void ToString(std::ostream &str) const; + + virtual const SEScalar* GetScalar(const std::string& name); + protected: bool m_StartImmediately; diff --git a/src/cpp/cdm/patient/actions/SEConsumeNutrients.cpp b/src/cpp/cdm/patient/actions/SEConsumeNutrients.cpp index d93e339ee06f97337f4c90f54c9f7c0057ff0480..6fa58deeceaefa631388936ddca15370c152f850 100644 --- a/src/cpp/cdm/patient/actions/SEConsumeNutrients.cpp +++ b/src/cpp/cdm/patient/actions/SEConsumeNutrients.cpp @@ -28,9 +28,11 @@ void SEConsumeNutrients::Clear() m_NutritionFile = ""; } -void SEConsumeNutrients::Copy(const SEConsumeNutrients& src) +void SEConsumeNutrients::Copy(const SEConsumeNutrients& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEConsumeNutrients::IsValid() const @@ -40,7 +42,17 @@ bool SEConsumeNutrients::IsValid() const bool SEConsumeNutrients::IsActive() const { - return IsValid(); + return SEPatientAction::IsActive(); +} +void SEConsumeNutrients::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEConsumeNutrients::GetScalar(const std::string& name) +{ + return GetNutrition().GetScalar(name); } bool SEConsumeNutrients::HasNutrition() const diff --git a/src/cpp/cdm/patient/actions/SEConsumeNutrients.h b/src/cpp/cdm/patient/actions/SEConsumeNutrients.h index 22e1cf5f780de6ae5864b6f679ce9aa84021d25b..3c1e2804f43dabc7a1582086140a7c32ec2f3fb0 100644 --- a/src/cpp/cdm/patient/actions/SEConsumeNutrients.h +++ b/src/cpp/cdm/patient/actions/SEConsumeNutrients.h @@ -15,10 +15,11 @@ public: virtual ~SEConsumeNutrients(); virtual void Clear(); //clear memory - virtual void Copy(const SEConsumeNutrients& src); + virtual void Copy(const SEConsumeNutrients& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); bool HasNutrition() const; SENutrition& GetNutrition(); @@ -30,6 +31,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SENutrition* m_Nutrition; std::string m_NutritionFile; diff --git a/src/cpp/cdm/patient/actions/SEDyspnea.cpp b/src/cpp/cdm/patient/actions/SEDyspnea.cpp index 06a0d98dccfdc5b0aa9a8b6ddcee175e06cf52e0..c106fc6276d0abeb6629dad236f7b975bc7c32ee 100644 --- a/src/cpp/cdm/patient/actions/SEDyspnea.cpp +++ b/src/cpp/cdm/patient/actions/SEDyspnea.cpp @@ -22,9 +22,11 @@ void SEDyspnea::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEDyspnea::Copy(const SEDyspnea& src) +void SEDyspnea::Copy(const SEDyspnea& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEDyspnea::IsValid() const @@ -34,7 +36,21 @@ bool SEDyspnea::IsValid() const bool SEDyspnea::IsActive() const { - return IsValid() ? !m_Severity->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_Severity->IsZero(); +} +void SEDyspnea::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEDyspnea::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; } bool SEDyspnea::HasSeverity() const diff --git a/src/cpp/cdm/patient/actions/SEDyspnea.h b/src/cpp/cdm/patient/actions/SEDyspnea.h index 6bff13bf63a195579eab7d9b6253947618d17f88..df2c050737abe849dbd1a33236fe763cd495e5c5 100644 --- a/src/cpp/cdm/patient/actions/SEDyspnea.h +++ b/src/cpp/cdm/patient/actions/SEDyspnea.h @@ -13,10 +13,11 @@ public: virtual ~SEDyspnea(); virtual void Clear(); - virtual void Copy(const SEDyspnea& src); + virtual void Copy(const SEDyspnea& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -24,6 +25,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; }; diff --git a/src/cpp/cdm/patient/actions/SEExercise.cpp b/src/cpp/cdm/patient/actions/SEExercise.cpp index 08a1fb4e50729c00ffd3545159eea3121a421ed1..27afadfe6a0736265d7fa32f5d3b4a9494caa458 100644 --- a/src/cpp/cdm/patient/actions/SEExercise.cpp +++ b/src/cpp/cdm/patient/actions/SEExercise.cpp @@ -22,9 +22,11 @@ void SEExercise::Clear() INVALIDATE_PROPERTY(m_Intensity); } -void SEExercise::Copy(const SEExercise& src) +void SEExercise::Copy(const SEExercise& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEExercise::IsValid() const @@ -34,9 +36,23 @@ bool SEExercise::IsValid() const bool SEExercise::IsActive() const { + if (!SEPatientAction::IsActive()) + return false; if (HasIntensity()) return m_Intensity->IsPositive(); - return false; + return false; +} +void SEExercise::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEExercise::GetScalar(const std::string& name) +{ + if (name.compare("Intensity") == 0) + return &GetIntensity(); + return nullptr; } bool SEExercise::HasIntensity() const diff --git a/src/cpp/cdm/patient/actions/SEExercise.h b/src/cpp/cdm/patient/actions/SEExercise.h index c0804b7dd717a946acd83989572eaa000dc928f5..fbd919dbabcc4447714a5ad411c3c0cf3e9df946 100644 --- a/src/cpp/cdm/patient/actions/SEExercise.h +++ b/src/cpp/cdm/patient/actions/SEExercise.h @@ -13,10 +13,11 @@ public: virtual ~SEExercise(); virtual void Clear(); //clear memory - virtual void Copy(const SEExercise& src); + virtual void Copy(const SEExercise& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasIntensity() const; virtual SEScalar0To1& GetIntensity(); @@ -24,6 +25,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Intensity; }; diff --git a/src/cpp/cdm/patient/actions/SEHemorrhage.cpp b/src/cpp/cdm/patient/actions/SEHemorrhage.cpp index d31283653af6669b242fd3fdf0a871654d1415d5..9033195da782adbe38ca4f6f5832f4db7553757d 100644 --- a/src/cpp/cdm/patient/actions/SEHemorrhage.cpp +++ b/src/cpp/cdm/patient/actions/SEHemorrhage.cpp @@ -4,6 +4,7 @@ #include "stdafx.h" #include "patient/actions/SEHemorrhage.h" #include "properties/SEScalar0To1.h" +#include "properties/SEScalarVolume.h" #include "properties/SEScalarVolumePerTime.h" #include "io/protobuf/PBPatientActions.h" @@ -12,6 +13,7 @@ SEHemorrhage::SEHemorrhage(Logger* logger) : SEPatientAction(logger) m_Compartment = ""; m_FlowRate=nullptr; m_Severity = nullptr; + m_TotalBloodLost = nullptr; m_Type = eHemorrhage_Type::External; } @@ -20,6 +22,7 @@ SEHemorrhage::~SEHemorrhage() m_Compartment = ""; SAFE_DELETE(m_FlowRate); SAFE_DELETE(m_Severity); + SAFE_DELETE(m_TotalBloodLost); m_Type = eHemorrhage_Type::External; } @@ -29,12 +32,27 @@ void SEHemorrhage::Clear() m_Compartment = ""; INVALIDATE_PROPERTY(m_FlowRate); INVALIDATE_PROPERTY(m_Severity); + INVALIDATE_PROPERTY(m_TotalBloodLost); m_Type = eHemorrhage_Type::External; } -void SEHemorrhage::Copy(const SEHemorrhage& src) +void SEHemorrhage::Copy(const SEHemorrhage& src, bool preserveState) { + static double v; + static const VolumeUnit* vu; + if (preserveState) + { + vu = nullptr; + if (HasTotalBloodLost()) + { + vu = GetTotalBloodLost().GetUnit(); + v = GetTotalBloodLost(*vu); + } + } PBPatientAction::Copy(src, *this); + // Put back any state + if (preserveState && vu != nullptr) + GetTotalBloodLost().SetValue(v, *vu); } bool SEHemorrhage::IsValid() const @@ -44,14 +62,32 @@ bool SEHemorrhage::IsValid() const bool SEHemorrhage::IsActive() const { - if (!IsValid()) + if (!SEPatientAction::IsActive()) return false; - if (HasFlowRate() && m_FlowRate->IsPositive()) + if (HasSeverity()) return true; - if (HasSeverity() && m_Severity->IsPositive()) + if (HasFlowRate()) return true; return false; } +void SEHemorrhage::Deactivate() +{ + SEPatientAction::Deactivate(); + INVALIDATE_PROPERTY(m_FlowRate); + INVALIDATE_PROPERTY(m_Severity); + // Keep the other variables, as they are state +} + +const SEScalar* SEHemorrhage::GetScalar(const std::string& name) +{ + if (name.compare("FlowRate") == 0) + return &GetFlowRate(); + if (name.compare("Severity") == 0) + return &GetSeverity(); + if (name.compare("TotalBloodLost") == 0) + return &GetTotalBloodLost(); + return nullptr; +} eHemorrhage_Type SEHemorrhage::GetType() const { @@ -116,6 +152,22 @@ double SEHemorrhage::GetSeverity() const return m_Severity->GetValue(); } +bool SEHemorrhage::HasTotalBloodLost() const +{ + return m_TotalBloodLost == nullptr ? false : m_TotalBloodLost->IsValid(); +} +SEScalarVolume& SEHemorrhage::GetTotalBloodLost() +{ + if (m_TotalBloodLost == nullptr) + m_TotalBloodLost = new SEScalarVolume(); + return *m_TotalBloodLost; +} +double SEHemorrhage::GetTotalBloodLost(const VolumeUnit& unit) const +{ + if (m_TotalBloodLost == nullptr) + return SEScalar::dNaN(); + return m_TotalBloodLost->GetValue(unit); +} void SEHemorrhage::ToString(std::ostream &str) const { @@ -126,5 +178,6 @@ void SEHemorrhage::ToString(std::ostream &str) const str << "\n\tFor Compartment: "; HasCompartment()? str << GetCompartment() : str << "No Compartment Set"; str << "\n\tFlowRate: "; HasFlowRate() ? str << *m_FlowRate : str << "Not Set"; str << "\n\tSeverity: "; HasSeverity() ? str << *m_Severity : str << "Not Set"; + str << "\n\tTotalBloodLost: "; HasTotalBloodLost() ? str << *m_TotalBloodLost : str << "Not Set"; str << std::flush; } diff --git a/src/cpp/cdm/patient/actions/SEHemorrhage.h b/src/cpp/cdm/patient/actions/SEHemorrhage.h index 2b73536f9f4a62c620693281e6c6e64c6d3854d4..26751a43b221533325749d18a09dd74d390247ed 100644 --- a/src/cpp/cdm/patient/actions/SEHemorrhage.h +++ b/src/cpp/cdm/patient/actions/SEHemorrhage.h @@ -17,10 +17,11 @@ public: virtual ~SEHemorrhage(); virtual void Clear(); //clear memory - virtual void Copy(const SEHemorrhage& src); + virtual void Copy(const SEHemorrhage& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual eHemorrhage_Type GetType() const; virtual void SetType(eHemorrhage_Type t); @@ -38,11 +39,18 @@ public: virtual SEScalar0To1& GetSeverity(); virtual double GetSeverity() const; + virtual bool HasTotalBloodLost() const; + virtual SEScalarVolume& GetTotalBloodLost(); + virtual double GetTotalBloodLost(const VolumeUnit& unit) const; + virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: eHemorrhage_Type m_Type; std::string m_Compartment; SEScalarVolumePerTime* m_FlowRate; SEScalar0To1* m_Severity; + SEScalarVolume* m_TotalBloodLost; }; \ No newline at end of file diff --git a/src/cpp/cdm/patient/actions/SEImpairedAlveolarExchangeExacerbation.cpp b/src/cpp/cdm/patient/actions/SEImpairedAlveolarExchangeExacerbation.cpp index 19d4eb667ec1801c51e3f73b66f29242a41a196c..52d99241affad9a750daa567cec73c14b3ab4114 100644 --- a/src/cpp/cdm/patient/actions/SEImpairedAlveolarExchangeExacerbation.cpp +++ b/src/cpp/cdm/patient/actions/SEImpairedAlveolarExchangeExacerbation.cpp @@ -27,9 +27,11 @@ void SEImpairedAlveolarExchangeExacerbation::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEImpairedAlveolarExchangeExacerbation::Copy(const SEImpairedAlveolarExchangeExacerbation & src) +void SEImpairedAlveolarExchangeExacerbation::Copy(const SEImpairedAlveolarExchangeExacerbation & src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEImpairedAlveolarExchangeExacerbation::IsValid() const @@ -39,7 +41,7 @@ bool SEImpairedAlveolarExchangeExacerbation::IsValid() const bool SEImpairedAlveolarExchangeExacerbation::IsActive() const { - if (!IsValid()) + if (!SEPatientAction::IsActive()) return false; if (GetImpairedFraction() > 0) return true; @@ -49,6 +51,22 @@ bool SEImpairedAlveolarExchangeExacerbation::IsActive() const return true; return false; } +void SEImpairedAlveolarExchangeExacerbation::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEImpairedAlveolarExchangeExacerbation::GetScalar(const std::string& name) +{ + if (name.compare("ImpairedSurfaceArea") == 0) + return &GetImpairedSurfaceArea(); + if (name.compare("ImpairedFraction") == 0) + return &GetImpairedFraction(); + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; +} bool SEImpairedAlveolarExchangeExacerbation::HasImpairedSurfaceArea() const { diff --git a/src/cpp/cdm/patient/actions/SEImpairedAlveolarExchangeExacerbation.h b/src/cpp/cdm/patient/actions/SEImpairedAlveolarExchangeExacerbation.h index 91d816299e7442b1da9c7a6df498687279fb17d4..b14721c0bcdfa7e72b7630159db4420bed9a5e3e 100644 --- a/src/cpp/cdm/patient/actions/SEImpairedAlveolarExchangeExacerbation.h +++ b/src/cpp/cdm/patient/actions/SEImpairedAlveolarExchangeExacerbation.h @@ -12,10 +12,11 @@ public: virtual ~SEImpairedAlveolarExchangeExacerbation(); virtual void Clear(); - virtual void Copy(const SEImpairedAlveolarExchangeExacerbation& src); + virtual void Copy(const SEImpairedAlveolarExchangeExacerbation& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasImpairedSurfaceArea() const; virtual SEScalarArea& GetImpairedSurfaceArea(); @@ -31,6 +32,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalarArea* m_ImpairedSurfaceArea; diff --git a/src/cpp/cdm/patient/actions/SEIntubation.cpp b/src/cpp/cdm/patient/actions/SEIntubation.cpp index 4e435fadf51727bd772e0b135412b02c2f7a8196..a83e7670691f9e44f85dfb5e86b0090fbf4a88ff 100644 --- a/src/cpp/cdm/patient/actions/SEIntubation.cpp +++ b/src/cpp/cdm/patient/actions/SEIntubation.cpp @@ -21,11 +21,12 @@ void SEIntubation::Clear() m_Type = eIntubation_Type::Off; } -void SEIntubation::Copy(const SEIntubation& src) +void SEIntubation::Copy(const SEIntubation& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } - bool SEIntubation::IsValid() const { return true; @@ -33,8 +34,20 @@ bool SEIntubation::IsValid() const bool SEIntubation::IsActive() const { + if (!SEPatientAction::IsActive()) + return false; return GetType() != eIntubation_Type::Off; } +void SEIntubation::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEIntubation::GetScalar(const std::string& name) +{ + return nullptr; +} eIntubation_Type SEIntubation::GetType() const { diff --git a/src/cpp/cdm/patient/actions/SEIntubation.h b/src/cpp/cdm/patient/actions/SEIntubation.h index 6ee1e708d9608f4c1cd7be846105a86072f068d3..2e8e2d0ed2b9c6a9519046d2d669f7c825200ced 100644 --- a/src/cpp/cdm/patient/actions/SEIntubation.h +++ b/src/cpp/cdm/patient/actions/SEIntubation.h @@ -17,15 +17,19 @@ public: virtual ~SEIntubation(); virtual void Clear(); //clear memory - virtual void Copy(const SEIntubation& src); + virtual void Copy(const SEIntubation& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual eIntubation_Type GetType() const; virtual void SetType(eIntubation_Type t); virtual void ToString(std::ostream &str) const; + + virtual const SEScalar* GetScalar(const std::string& name); + protected: eIntubation_Type m_Type; }; \ No newline at end of file diff --git a/src/cpp/cdm/patient/actions/SELobarPneumoniaExacerbation.cpp b/src/cpp/cdm/patient/actions/SELobarPneumoniaExacerbation.cpp index ce0eb0a21a6439ff55c3456f8ef40c5f1aaae594..1884289eb0c0338d996e91df4f071838d966e342 100644 --- a/src/cpp/cdm/patient/actions/SELobarPneumoniaExacerbation.cpp +++ b/src/cpp/cdm/patient/actions/SELobarPneumoniaExacerbation.cpp @@ -28,9 +28,11 @@ void SELobarPneumoniaExacerbation::Clear() INVALIDATE_PROPERTY(m_RightLungAffected); } -void SELobarPneumoniaExacerbation::Copy(const SELobarPneumoniaExacerbation& src) +void SELobarPneumoniaExacerbation::Copy(const SELobarPneumoniaExacerbation& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SELobarPneumoniaExacerbation::IsValid() const @@ -40,7 +42,7 @@ bool SELobarPneumoniaExacerbation::IsValid() const bool SELobarPneumoniaExacerbation::IsActive() const { - if (!IsValid()) + if (!SEPatientAction::IsActive()) return false; if (GetSeverity() <= 0) return false; @@ -48,6 +50,22 @@ bool SELobarPneumoniaExacerbation::IsActive() const return false; return true; } +void SELobarPneumoniaExacerbation::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SELobarPneumoniaExacerbation::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + if (name.compare("LeftLungAffected") == 0) + return &GetLeftLungAffected(); + if (name.compare("RightLungAffected") == 0) + return &GetRightLungAffected(); + return nullptr; +} bool SELobarPneumoniaExacerbation::HasSeverity() const { diff --git a/src/cpp/cdm/patient/actions/SELobarPneumoniaExacerbation.h b/src/cpp/cdm/patient/actions/SELobarPneumoniaExacerbation.h index 96572d9b0873fe6712495167b5aadf7d2043fdc8..a9a4aa96049235c1db75d7868246e26e1043c663 100644 --- a/src/cpp/cdm/patient/actions/SELobarPneumoniaExacerbation.h +++ b/src/cpp/cdm/patient/actions/SELobarPneumoniaExacerbation.h @@ -13,10 +13,11 @@ public: virtual ~SELobarPneumoniaExacerbation(); virtual void Clear(); //clear memory - virtual void Copy(const SELobarPneumoniaExacerbation& src); + virtual void Copy(const SELobarPneumoniaExacerbation& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -32,6 +33,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; diff --git a/src/cpp/cdm/patient/actions/SEMechanicalVentilation.cpp b/src/cpp/cdm/patient/actions/SEMechanicalVentilation.cpp index 53af835de2d2b50abd46589dca22ba1e9dcb2b41..d00a62c425c0a4e747f13dcfa40e739ceef670a5 100644 --- a/src/cpp/cdm/patient/actions/SEMechanicalVentilation.cpp +++ b/src/cpp/cdm/patient/actions/SEMechanicalVentilation.cpp @@ -47,9 +47,11 @@ void SEMechanicalVentilation::Clear() sc->Clear(); } -void SEMechanicalVentilation::Copy(const SEMechanicalVentilation& src, const SESubstanceManager& subMgr) +void SEMechanicalVentilation::Copy(const SEMechanicalVentilation& src, const SESubstanceManager& subMgr, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this, subMgr); + //if(preserveState) // Put back any state } bool SEMechanicalVentilation::IsValid() const @@ -82,8 +84,24 @@ bool SEMechanicalVentilation::IsValid() const bool SEMechanicalVentilation::IsActive() const { + if (!SEPatientAction::IsActive()) + return false; return GetState() == eSwitch::On; } +void SEMechanicalVentilation::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEMechanicalVentilation::GetScalar(const std::string& name) +{ + if (name.compare("Flow") == 0) + return &GetFlow(); + if (name.compare("Pressure") == 0) + return &GetPressure(); + return nullptr; +} eSwitch SEMechanicalVentilation::GetState() const { diff --git a/src/cpp/cdm/patient/actions/SEMechanicalVentilation.h b/src/cpp/cdm/patient/actions/SEMechanicalVentilation.h index afab42534bc8a195c28b70c00a59dc8a7f01947b..5dcaa5519b8976ee3f84cc6b66d12d7beac66192 100644 --- a/src/cpp/cdm/patient/actions/SEMechanicalVentilation.h +++ b/src/cpp/cdm/patient/actions/SEMechanicalVentilation.h @@ -20,10 +20,11 @@ public: virtual ~SEMechanicalVentilation(); virtual void Clear(); - virtual void Copy(const SEMechanicalVentilation& src, const SESubstanceManager& subMgr); + virtual void Copy(const SEMechanicalVentilation& src, const SESubstanceManager& subMgr, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual eSwitch GetState() const; virtual void SetState(eSwitch name); @@ -55,6 +56,9 @@ public: void RemoveAerosols(); virtual void ToString(std::ostream &str) const; + + virtual const SEScalar* GetScalar(const std::string& name); + protected: eSwitch m_State; diff --git a/src/cpp/cdm/patient/actions/SENeedleDecompression.cpp b/src/cpp/cdm/patient/actions/SENeedleDecompression.cpp index f85bbcb4422371f577bfe61b4f2ed0f80c7010e8..371c6635e870a3e33b791c472c6d6612b83befd8 100644 --- a/src/cpp/cdm/patient/actions/SENeedleDecompression.cpp +++ b/src/cpp/cdm/patient/actions/SENeedleDecompression.cpp @@ -24,9 +24,11 @@ void SENeedleDecompression::Clear() m_Side= eSide::NullSide; } -void SENeedleDecompression::Copy(const SENeedleDecompression& src) +void SENeedleDecompression::Copy(const SENeedleDecompression& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SENeedleDecompression::IsValid() const @@ -36,12 +38,19 @@ bool SENeedleDecompression::IsValid() const bool SENeedleDecompression::IsActive() const { - return IsValid() && m_State == eSwitch::On; + if (!SEPatientAction::IsActive()) + return false; + return m_State == eSwitch::On; +} +void SENeedleDecompression::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties } -void SENeedleDecompression::SetActive(bool b) +const SEScalar* SENeedleDecompression::GetScalar(const std::string& name) { - m_State = b ? eSwitch::On : eSwitch::Off; + return nullptr; } eSwitch SENeedleDecompression::GetState() const diff --git a/src/cpp/cdm/patient/actions/SENeedleDecompression.h b/src/cpp/cdm/patient/actions/SENeedleDecompression.h index 9eaa1d5e1644e53e970f443113d6328223221023..818d12c07a4ab5e04798b079ae7971e432a879e1 100644 --- a/src/cpp/cdm/patient/actions/SENeedleDecompression.h +++ b/src/cpp/cdm/patient/actions/SENeedleDecompression.h @@ -13,11 +13,11 @@ public: virtual ~SENeedleDecompression(); virtual void Clear(); //clear memory - virtual void Copy(const SENeedleDecompression& src); + virtual void Copy(const SENeedleDecompression& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; - virtual void SetActive(bool b); + virtual void Deactivate(); virtual eSwitch GetState() const; virtual void SetState(eSwitch name); @@ -29,6 +29,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: eSide m_Side; eSwitch m_State; diff --git a/src/cpp/cdm/patient/actions/SEPatientAssessmentRequest.cpp b/src/cpp/cdm/patient/actions/SEPatientAssessmentRequest.cpp index edc4517e6c4b537b68e7d1d852ce997bf3a430b6..5c1cf0ed57de6d96c1f3d2d43b8c608476703ba7 100644 --- a/src/cpp/cdm/patient/actions/SEPatientAssessmentRequest.cpp +++ b/src/cpp/cdm/patient/actions/SEPatientAssessmentRequest.cpp @@ -21,9 +21,11 @@ void SEPatientAssessmentRequest::Clear() m_Type=ePatientAssessment_Type::CompleteBloodCount; } -void SEPatientAssessmentRequest::Copy(const SEPatientAssessmentRequest& src) +void SEPatientAssessmentRequest::Copy(const SEPatientAssessmentRequest& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEPatientAssessmentRequest::IsValid() const @@ -33,7 +35,17 @@ bool SEPatientAssessmentRequest::IsValid() const bool SEPatientAssessmentRequest::IsActive() const { - return IsValid(); + return SEPatientAction::IsActive(); +} +void SEPatientAssessmentRequest::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEPatientAssessmentRequest::GetScalar(const std::string& name) +{ + return nullptr; } ePatientAssessment_Type SEPatientAssessmentRequest::GetType() const diff --git a/src/cpp/cdm/patient/actions/SEPatientAssessmentRequest.h b/src/cpp/cdm/patient/actions/SEPatientAssessmentRequest.h index 19d899c7e77d252cb86fddf143db7e74e98ef7d8..711233e618f636746f2622023037b7f5d6f84137 100644 --- a/src/cpp/cdm/patient/actions/SEPatientAssessmentRequest.h +++ b/src/cpp/cdm/patient/actions/SEPatientAssessmentRequest.h @@ -14,15 +14,18 @@ public: virtual ~SEPatientAssessmentRequest(); virtual void Clear(); //clear memory - virtual void Copy(const SEPatientAssessmentRequest& src); + virtual void Copy(const SEPatientAssessmentRequest& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual ePatientAssessment_Type GetType() const; virtual void SetType(ePatientAssessment_Type type); virtual void ToString(std::ostream &str) const; + + virtual const SEScalar* GetScalar(const std::string& name); protected: diff --git a/src/cpp/cdm/patient/actions/SEPericardialEffusion.cpp b/src/cpp/cdm/patient/actions/SEPericardialEffusion.cpp index 3b2a1dec88a654462c4e8f4f7cbd7ad0b94a73a4..851a05f9eaaffbb7260fee366535bb0daa96add0 100644 --- a/src/cpp/cdm/patient/actions/SEPericardialEffusion.cpp +++ b/src/cpp/cdm/patient/actions/SEPericardialEffusion.cpp @@ -22,9 +22,11 @@ void SEPericardialEffusion::Clear() INVALIDATE_PROPERTY(m_EffusionRate); } -void SEPericardialEffusion::Copy(const SEPericardialEffusion& src) +void SEPericardialEffusion::Copy(const SEPericardialEffusion& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEPericardialEffusion::IsValid() const @@ -34,7 +36,21 @@ bool SEPericardialEffusion::IsValid() const bool SEPericardialEffusion::IsActive() const { - return IsValid() ? !m_EffusionRate->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_EffusionRate->IsZero(); +} +void SEPericardialEffusion::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEPericardialEffusion::GetScalar(const std::string& name) +{ + if (name.compare("EffusionRate") == 0) + return &GetEffusionRate(); + return nullptr; } bool SEPericardialEffusion::HasEffusionRate() const diff --git a/src/cpp/cdm/patient/actions/SEPericardialEffusion.h b/src/cpp/cdm/patient/actions/SEPericardialEffusion.h index 53f36f875666ac92644c881cee9269e19699b5e1..db4db87d667dcec3f5cd657da0e9d725ef2caf8d 100644 --- a/src/cpp/cdm/patient/actions/SEPericardialEffusion.h +++ b/src/cpp/cdm/patient/actions/SEPericardialEffusion.h @@ -13,10 +13,11 @@ public: virtual ~SEPericardialEffusion(); virtual void Clear(); //clear memory - virtual void Copy(const SEPericardialEffusion& src); + virtual void Copy(const SEPericardialEffusion& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasEffusionRate() const; virtual SEScalarVolumePerTime& GetEffusionRate(); @@ -24,6 +25,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalarVolumePerTime* m_EffusionRate; }; diff --git a/src/cpp/cdm/patient/actions/SEPulmonaryShuntExacerbation.cpp b/src/cpp/cdm/patient/actions/SEPulmonaryShuntExacerbation.cpp index 5e49da38f2cf53d6d10b8b76260ba012d5b780a9..f85d0c108c1d51ec319a5e737f8f8c7ec2593d70 100644 --- a/src/cpp/cdm/patient/actions/SEPulmonaryShuntExacerbation.cpp +++ b/src/cpp/cdm/patient/actions/SEPulmonaryShuntExacerbation.cpp @@ -22,9 +22,11 @@ void SEPulmonaryShuntExacerbation::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEPulmonaryShuntExacerbation::Copy(const SEPulmonaryShuntExacerbation& src) +void SEPulmonaryShuntExacerbation::Copy(const SEPulmonaryShuntExacerbation& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEPulmonaryShuntExacerbation::IsValid() const @@ -34,7 +36,21 @@ bool SEPulmonaryShuntExacerbation::IsValid() const bool SEPulmonaryShuntExacerbation::IsActive() const { - return IsValid() ? !m_Severity->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_Severity->IsZero(); +} +void SEPulmonaryShuntExacerbation::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEPulmonaryShuntExacerbation::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; } bool SEPulmonaryShuntExacerbation::HasSeverity() const diff --git a/src/cpp/cdm/patient/actions/SEPulmonaryShuntExacerbation.h b/src/cpp/cdm/patient/actions/SEPulmonaryShuntExacerbation.h index 14aed91269f9f9d89cc2f1e29eea7314e39fd42d..d299c8e05f875a728001d2dc1d8dec927d818916 100644 --- a/src/cpp/cdm/patient/actions/SEPulmonaryShuntExacerbation.h +++ b/src/cpp/cdm/patient/actions/SEPulmonaryShuntExacerbation.h @@ -13,10 +13,11 @@ public: virtual ~SEPulmonaryShuntExacerbation(); virtual void Clear(); - virtual void Copy(const SEPulmonaryShuntExacerbation& src); + virtual void Copy(const SEPulmonaryShuntExacerbation& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -24,6 +25,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; }; \ No newline at end of file diff --git a/src/cpp/cdm/patient/actions/SERespiratoryFatigue.cpp b/src/cpp/cdm/patient/actions/SERespiratoryFatigue.cpp index fd061be7ae14da580499ff0147cc99d0081c83b5..fa2c19c118dd7e53393a0b06473b2b3434111233 100644 --- a/src/cpp/cdm/patient/actions/SERespiratoryFatigue.cpp +++ b/src/cpp/cdm/patient/actions/SERespiratoryFatigue.cpp @@ -22,9 +22,11 @@ void SERespiratoryFatigue::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SERespiratoryFatigue::Copy(const SERespiratoryFatigue& src) +void SERespiratoryFatigue::Copy(const SERespiratoryFatigue& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SERespiratoryFatigue::IsValid() const @@ -34,7 +36,21 @@ bool SERespiratoryFatigue::IsValid() const bool SERespiratoryFatigue::IsActive() const { - return IsValid() ? !m_Severity->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_Severity->IsZero(); +} +void SERespiratoryFatigue::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SERespiratoryFatigue::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; } bool SERespiratoryFatigue::HasSeverity() const diff --git a/src/cpp/cdm/patient/actions/SERespiratoryFatigue.h b/src/cpp/cdm/patient/actions/SERespiratoryFatigue.h index 3bcd5463ebdfa2c5770b2448cd36d49c071e7761..f9ee573e0df30d029ddc1aa397a80cef6d5c7fc7 100644 --- a/src/cpp/cdm/patient/actions/SERespiratoryFatigue.h +++ b/src/cpp/cdm/patient/actions/SERespiratoryFatigue.h @@ -13,10 +13,11 @@ public: virtual ~SERespiratoryFatigue(); virtual void Clear(); - virtual void Copy(const SERespiratoryFatigue& src); + virtual void Copy(const SERespiratoryFatigue& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -24,6 +25,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; }; diff --git a/src/cpp/cdm/patient/actions/SESubstanceAdministration.cpp b/src/cpp/cdm/patient/actions/SESubstanceAdministration.cpp index b2582957925018eb4b60d89104e599f1062fb8ef..2126f52df857189f9885dcfe2238bf8c5c1984e9 100644 --- a/src/cpp/cdm/patient/actions/SESubstanceAdministration.cpp +++ b/src/cpp/cdm/patient/actions/SESubstanceAdministration.cpp @@ -4,27 +4,3 @@ #include "stdafx.h" #include "patient/actions/SESubstanceAdministration.h" #include "io/protobuf/PBPatientActions.h" - -SESubstanceAdministration::SESubstanceAdministration(Logger* logger) : SEPatientAction(logger) -{ -} - -SESubstanceAdministration::~SESubstanceAdministration() -{ - -} - -void SESubstanceAdministration::Clear() -{ - SEPatientAction::Clear(); -} - -bool SESubstanceAdministration::IsValid() const -{ - return SEPatientAction::IsValid(); -} - -bool SESubstanceAdministration::IsActive() const -{ - return IsValid(); -} \ No newline at end of file diff --git a/src/cpp/cdm/patient/actions/SESubstanceAdministration.h b/src/cpp/cdm/patient/actions/SESubstanceAdministration.h index 5b184bc119f3b892d1094deb79d0d3cd381c285b..610a8ba39e4f20781dbf3809b33eff44d90d140f 100644 --- a/src/cpp/cdm/patient/actions/SESubstanceAdministration.h +++ b/src/cpp/cdm/patient/actions/SESubstanceAdministration.h @@ -18,18 +18,3 @@ enum class eSubstanceAdministration_Route { Subcutaneous }; extern const std::string& eSubstanceAdministration_Route_Name(eSubstanceAdministration_Route m); - -class CDM_DECL SESubstanceAdministration : public SEPatientAction -{ - friend class PBPatientAction;//friend the serialization class -public: - - SESubstanceAdministration(Logger* logger); - virtual ~SESubstanceAdministration(); - - virtual void Clear(); //clear memory - - virtual bool IsValid() const; - virtual bool IsActive() const; - -}; \ No newline at end of file diff --git a/src/cpp/cdm/patient/actions/SESubstanceBolus.cpp b/src/cpp/cdm/patient/actions/SESubstanceBolus.cpp index 46d93d691fa3f39ec760ee869ad7e09bc6531e2c..601d1b59daba934e76a3a3fbaadf220fa4eb9d68 100644 --- a/src/cpp/cdm/patient/actions/SESubstanceBolus.cpp +++ b/src/cpp/cdm/patient/actions/SESubstanceBolus.cpp @@ -9,10 +9,11 @@ #include "properties/SEScalarTime.h" #include "io/protobuf/PBPatientActions.h" -SESubstanceBolus::SESubstanceBolus(const SESubstance& substance, Logger* logger) : SESubstanceAdministration(logger), m_Substance(substance), m_State(substance) +SESubstanceBolus::SESubstanceBolus(const SESubstance& substance, Logger* logger) : SEPatientAction(logger), m_Substance(substance) { m_AdminRoute=eSubstanceAdministration_Route::Intravenous; m_AdminDuration=nullptr; + m_AdministeredDose = nullptr; m_Dose=nullptr; m_Concentration=nullptr; } @@ -21,34 +22,61 @@ SESubstanceBolus::~SESubstanceBolus() { m_AdminRoute = eSubstanceAdministration_Route::Intravenous; SAFE_DELETE(m_AdminDuration); + SAFE_DELETE(m_AdministeredDose); SAFE_DELETE(m_Dose); SAFE_DELETE(m_Concentration); - m_State.Clear(); } void SESubstanceBolus::Clear() { - SESubstanceAdministration::Clear(); + SEPatientAction::Clear(); m_AdminRoute=eSubstanceAdministration_Route::Intravenous; INVALIDATE_PROPERTY(m_AdminDuration); + INVALIDATE_PROPERTY(m_AdministeredDose); INVALIDATE_PROPERTY(m_Dose); INVALIDATE_PROPERTY(m_Concentration); - m_State.Clear(); } -void SESubstanceBolus::Copy(const SESubstanceBolus& src) +void SESubstanceBolus::Copy(const SESubstanceBolus& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SESubstanceBolus::IsValid() const { - return SESubstanceAdministration::IsValid() && HasDose() && HasConcentration(); + return SEPatientAction::IsValid() && HasDose() && HasConcentration(); } bool SESubstanceBolus::IsActive() const { - return IsValid(); + if (!SEPatientAction::IsActive()) + return false; + return !m_Dose->IsZero() && !m_Concentration->IsZero(); +} +void SESubstanceBolus::Activate() +{ + SEPatientAction::Activate(); + GetAdministeredDose().SetValue(0, VolumeUnit::mL); +} +void SESubstanceBolus::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SESubstanceBolus::GetScalar(const std::string& name) +{ + if (name.compare("AdminDuration") == 0) + return &GetAdminDuration(); + if (name.compare("AdministeredDose") == 0) + return &GetAdministeredDose(); + if (name.compare("Dose") == 0) + return &GetDose(); + if (name.compare("Concentration") == 0) + return &GetConcentration(); + return nullptr; } eSubstanceAdministration_Route SESubstanceBolus::GetAdminRoute() const @@ -77,6 +105,23 @@ double SESubstanceBolus::GetAdminDuration(const TimeUnit& unit) const return m_AdminDuration->GetValue(unit); } +bool SESubstanceBolus::HasAdministeredDose() const +{ + return m_AdministeredDose == nullptr ? false : m_AdministeredDose->IsValid(); +} +SEScalarVolume& SESubstanceBolus::GetAdministeredDose() +{ + if (m_AdministeredDose == nullptr) + m_AdministeredDose = new SEScalarVolume(); + return *m_AdministeredDose; +} +double SESubstanceBolus::GetAdministeredDose(const VolumeUnit& unit) const +{ + if (m_AdministeredDose == nullptr) + return SEScalar::dNaN(); + return m_AdministeredDose->GetValue(unit); +} + bool SESubstanceBolus::HasDose() const { return m_Dose==nullptr?false:m_Dose->IsValid(); @@ -130,37 +175,6 @@ void SESubstanceBolus::ToString(std::ostream &str) const str << "\n\tAdministration Duration: "; HasAdminDuration() ? str << *m_AdminDuration : str << "No Administration Duration Set"; str << "\n\tDose: "; HasDose()? str << *m_Dose : str << "No Dose Set"; str << "\n\tConcentration: "; HasConcentration()? str << *m_Concentration : str << "NaN"; + str << "\n\AdministeredDose: "; HasAdministeredDose() ? str << *m_AdministeredDose : str << "NaN"; str << std::flush; } - -SESubstanceBolusState::SESubstanceBolusState(const SESubstance& sub, Logger* logger) : Loggable(logger), m_Substance(sub) -{ - m_ElapsedTime = new SEScalarTime(); - m_AdministeredDose = new SEScalarVolume(); - Clear(); -} -SESubstanceBolusState::~SESubstanceBolusState() -{ - delete m_ElapsedTime; - delete m_AdministeredDose; -} - -void SESubstanceBolusState::Clear() -{ - m_ElapsedTime->SetValue(0, TimeUnit::s); - m_AdministeredDose->SetValue(0, VolumeUnit::mL); -} - -double SESubstanceBolusState::GetElapsedTime(const TimeUnit& unit) const -{ - if (m_ElapsedTime == nullptr) - return SEScalar::dNaN(); - return m_ElapsedTime->GetValue(unit); -} - -double SESubstanceBolusState::GetAdministeredDose(const VolumeUnit& unit) const -{ - if (m_AdministeredDose == nullptr) - return SEScalar::dNaN(); - return m_AdministeredDose->GetValue(unit); -} diff --git a/src/cpp/cdm/patient/actions/SESubstanceBolus.h b/src/cpp/cdm/patient/actions/SESubstanceBolus.h index d1fa8fa8427b390a1ad3d6e91405c17dce02889a..4a930a6eef10561fbc035b8040de9a29016e970c 100644 --- a/src/cpp/cdm/patient/actions/SESubstanceBolus.h +++ b/src/cpp/cdm/patient/actions/SESubstanceBolus.h @@ -5,28 +5,7 @@ #include "patient/actions/SESubstanceAdministration.h" class SESubstance; -class CDM_DECL SESubstanceBolusState : public Loggable -{ - friend class PBPatientAction;//friend the serialization class -public: - SESubstanceBolusState(const SESubstance& sub, Logger* logger=nullptr); - ~SESubstanceBolusState(); - - virtual void Clear(); - - SEScalarTime& GetElapsedTime() { return *m_ElapsedTime; } - double GetElapsedTime(const TimeUnit& unit) const; - - virtual SEScalarVolume& GetAdministeredDose() { return *m_AdministeredDose; } - virtual double GetAdministeredDose(const VolumeUnit& unit) const; - -protected: - const SESubstance& m_Substance; - SEScalarTime* m_ElapsedTime; - SEScalarVolume* m_AdministeredDose; -}; - -class CDM_DECL SESubstanceBolus : public SESubstanceAdministration +class CDM_DECL SESubstanceBolus : public SEPatientAction { friend class PBPatientAction;//friend the serialization class public: @@ -35,10 +14,12 @@ public: virtual ~SESubstanceBolus(); virtual void Clear(); //clear memory - virtual void Copy(const SESubstanceBolus& src); + virtual void Copy(const SESubstanceBolus& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Activate(); + virtual void Deactivate(); virtual eSubstanceAdministration_Route GetAdminRoute() const; virtual void SetAdminRoute(eSubstanceAdministration_Route name); @@ -58,16 +39,20 @@ public: virtual SESubstance& GetSubstance(); virtual const SESubstance& GetSubstance() const; - virtual SESubstanceBolusState& GetState() { return m_State; } - virtual const SESubstanceBolusState& GetState() const { return m_State; } - virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + + virtual bool HasAdministeredDose() const; + virtual SEScalarVolume& GetAdministeredDose(); + virtual double GetAdministeredDose(const VolumeUnit& unit) const; + protected: + const SESubstance& m_Substance; eSubstanceAdministration_Route m_AdminRoute; SEScalarTime* m_AdminDuration; + SEScalarVolume* m_AdministeredDose; SEScalarMassPerVolume* m_Concentration; SEScalarVolume* m_Dose; - SESubstanceBolusState m_State; }; diff --git a/src/cpp/cdm/patient/actions/SESubstanceCompoundInfusion.cpp b/src/cpp/cdm/patient/actions/SESubstanceCompoundInfusion.cpp index 5812da0a5229a54ae7cd05ec7b9c26be6c96d8fc..b470b64935d3e57fdc51ab76b12f474fe7204501 100644 --- a/src/cpp/cdm/patient/actions/SESubstanceCompoundInfusion.cpp +++ b/src/cpp/cdm/patient/actions/SESubstanceCompoundInfusion.cpp @@ -8,7 +8,7 @@ #include "properties/SEScalarVolume.h" #include "io/protobuf/PBPatientActions.h" -SESubstanceCompoundInfusion::SESubstanceCompoundInfusion(const SESubstanceCompound& compound, Logger* logger) : SESubstanceAdministration(logger), m_Compound(compound) +SESubstanceCompoundInfusion::SESubstanceCompoundInfusion(const SESubstanceCompound& compound, Logger* logger) : SEPatientAction(logger), m_Compound(compound) { m_Rate=nullptr; m_BagVolume=nullptr; @@ -23,25 +23,42 @@ SESubstanceCompoundInfusion::~SESubstanceCompoundInfusion() void SESubstanceCompoundInfusion::Clear() { - SESubstanceAdministration::Clear(); + SEPatientAction::Clear(); INVALIDATE_PROPERTY(m_Rate); INVALIDATE_PROPERTY(m_BagVolume); - // m_Compound=nullptr; Keeping mapping!! } -void SESubstanceCompoundInfusion::Copy(const SESubstanceCompoundInfusion& src) +void SESubstanceCompoundInfusion::Copy(const SESubstanceCompoundInfusion& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SESubstanceCompoundInfusion::IsValid() const { - return SESubstanceAdministration::IsValid() && HasRate() && HasBagVolume(); + return SEPatientAction::IsValid() && HasRate() && HasBagVolume(); } bool SESubstanceCompoundInfusion::IsActive() const { - return IsValid() ? !m_Rate->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_Rate->IsZero(); +} +void SESubstanceCompoundInfusion::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SESubstanceCompoundInfusion::GetScalar(const std::string& name) +{ + if (name.compare("Rate") == 0) + return &GetRate(); + if (name.compare("BagVolume") == 0) + return &GetBagVolume(); + return nullptr; } bool SESubstanceCompoundInfusion::HasRate() const diff --git a/src/cpp/cdm/patient/actions/SESubstanceCompoundInfusion.h b/src/cpp/cdm/patient/actions/SESubstanceCompoundInfusion.h index e96e7466ae6933a2afc29e7916dc328a1d542da2..d2b8c6a025f2a9c80d2d6bce98156fa7a3622f7b 100644 --- a/src/cpp/cdm/patient/actions/SESubstanceCompoundInfusion.h +++ b/src/cpp/cdm/patient/actions/SESubstanceCompoundInfusion.h @@ -5,7 +5,7 @@ #include "patient/actions/SESubstanceAdministration.h" class SESubstanceCompound; -class CDM_DECL SESubstanceCompoundInfusion : public SESubstanceAdministration +class CDM_DECL SESubstanceCompoundInfusion : public SEPatientAction { friend class PBPatientAction;//friend the serialization class public: @@ -14,10 +14,11 @@ public: virtual ~SESubstanceCompoundInfusion(); virtual void Clear(); //clear memory - virtual void Copy(const SESubstanceCompoundInfusion& src); + virtual void Copy(const SESubstanceCompoundInfusion& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasBagVolume() const; virtual SEScalarVolume& GetBagVolume(); @@ -32,6 +33,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalarVolume* m_BagVolume; SEScalarVolumePerTime* m_Rate; diff --git a/src/cpp/cdm/patient/actions/SESubstanceInfusion.cpp b/src/cpp/cdm/patient/actions/SESubstanceInfusion.cpp index 0e9c4e2a83280ec74510d3a44e4dc9e05daa63a4..389d68e5472533305d00a7a402e61b0c8d16bcc0 100644 --- a/src/cpp/cdm/patient/actions/SESubstanceInfusion.cpp +++ b/src/cpp/cdm/patient/actions/SESubstanceInfusion.cpp @@ -9,9 +9,8 @@ #include "properties/SEScalarMassPerVolume.h" #include "io/protobuf/PBPatientActions.h" -SESubstanceInfusion::SESubstanceInfusion(const SESubstance& substance, Logger* logger) : SESubstanceAdministration(logger), m_Substance(substance) +SESubstanceInfusion::SESubstanceInfusion(const SESubstance& substance, Logger* logger) : SEPatientAction(logger), m_Substance(substance) { - m_Rate=nullptr; m_Concentration=nullptr; } @@ -24,24 +23,42 @@ SESubstanceInfusion::~SESubstanceInfusion() void SESubstanceInfusion::Clear() { - SESubstanceAdministration::Clear(); + SEPatientAction::Clear(); INVALIDATE_PROPERTY(m_Rate); INVALIDATE_PROPERTY(m_Concentration); } -void SESubstanceInfusion::Copy(const SESubstanceInfusion& src) +void SESubstanceInfusion::Copy(const SESubstanceInfusion& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SESubstanceInfusion::IsValid() const { - return SESubstanceAdministration::IsValid() && HasRate() && HasConcentration(); + return SEPatientAction::IsValid() && HasRate() && HasConcentration(); } bool SESubstanceInfusion::IsActive() const { - return IsValid() ? !m_Rate->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_Rate->IsZero() && !m_Concentration->IsZero(); +} +void SESubstanceInfusion::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SESubstanceInfusion::GetScalar(const std::string& name) +{ + if (name.compare("Rate") == 0) + return &GetRate(); + if (name.compare("Concentration") == 0) + return &GetConcentration(); + return nullptr; } bool SESubstanceInfusion::HasRate() const diff --git a/src/cpp/cdm/patient/actions/SESubstanceInfusion.h b/src/cpp/cdm/patient/actions/SESubstanceInfusion.h index 4f83f32a5f94ca3474e2fc2602b96bc9856caa6a..e9df6cf9ed04248abcefecb2cba6c930fd790d58 100644 --- a/src/cpp/cdm/patient/actions/SESubstanceInfusion.h +++ b/src/cpp/cdm/patient/actions/SESubstanceInfusion.h @@ -5,7 +5,7 @@ #include "patient/actions/SESubstanceAdministration.h" class SESubstance; -class CDM_DECL SESubstanceInfusion : public SESubstanceAdministration +class CDM_DECL SESubstanceInfusion : public SEPatientAction { friend class PBPatientAction;//friend the serialization class public: @@ -14,10 +14,11 @@ public: virtual ~SESubstanceInfusion(); virtual void Clear(); //clear memory - virtual void Copy(const SESubstanceInfusion& src); + virtual void Copy(const SESubstanceInfusion& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasConcentration() const; virtual SEScalarMassPerVolume& GetConcentration(); @@ -32,6 +33,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalarMassPerVolume* m_Concentration; SEScalarVolumePerTime* m_Rate; diff --git a/src/cpp/cdm/patient/actions/SESupplementalOxygen.cpp b/src/cpp/cdm/patient/actions/SESupplementalOxygen.cpp index b9e81ece965fbd11889d4d1abdc9ea1ca5fc8b02..bb9ef0fe4fd490288d5840e3316842e3ebfd0502 100644 --- a/src/cpp/cdm/patient/actions/SESupplementalOxygen.cpp +++ b/src/cpp/cdm/patient/actions/SESupplementalOxygen.cpp @@ -29,9 +29,11 @@ void SESupplementalOxygen::Clear() INVALIDATE_PROPERTY(m_Volume); } -void SESupplementalOxygen::Copy(const SESupplementalOxygen& src) +void SESupplementalOxygen::Copy(const SESupplementalOxygen& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SESupplementalOxygen::IsValid() const @@ -39,6 +41,25 @@ bool SESupplementalOxygen::IsValid() const return SEPatientAction::IsValid(); } +bool SESupplementalOxygen::IsActive() const +{ + return SEPatientAction::IsActive(); +} +void SESupplementalOxygen::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SESupplementalOxygen::GetScalar(const std::string& name) +{ + if (name.compare("Flow") == 0) + return &GetFlow(); + if (name.compare("Volume") == 0) + return &GetVolume(); + return nullptr; +} + eSupplementalOxygen_Device SESupplementalOxygen::GetDevice() const { return m_Device; diff --git a/src/cpp/cdm/patient/actions/SESupplementalOxygen.h b/src/cpp/cdm/patient/actions/SESupplementalOxygen.h index d28609557e21f32e8f1328f1f60d602cd31e3fec..97c7c63b924f333a34a20a3d2136443a3251f6f0 100644 --- a/src/cpp/cdm/patient/actions/SESupplementalOxygen.h +++ b/src/cpp/cdm/patient/actions/SESupplementalOxygen.h @@ -18,9 +18,11 @@ public: virtual ~SESupplementalOxygen(); virtual void Clear(); //clear memory - virtual void Copy(const SESupplementalOxygen& src); + virtual void Copy(const SESupplementalOxygen& src, bool preserveState=false); virtual bool IsValid() const; + virtual bool IsActive() const; + virtual void Deactivate(); virtual eSupplementalOxygen_Device GetDevice() const; virtual void SetDevice(eSupplementalOxygen_Device name); @@ -35,6 +37,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: eSupplementalOxygen_Device m_Device; SEScalarVolumePerTime* m_Flow; diff --git a/src/cpp/cdm/patient/actions/SETensionPneumothorax.cpp b/src/cpp/cdm/patient/actions/SETensionPneumothorax.cpp index 19048efdd3f73baae6c0ea44fa7ea343ca92630f..5c6561be8340ee81714186f5eb9f64ab4ff00b5b 100644 --- a/src/cpp/cdm/patient/actions/SETensionPneumothorax.cpp +++ b/src/cpp/cdm/patient/actions/SETensionPneumothorax.cpp @@ -28,9 +28,11 @@ void SETensionPneumothorax::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SETensionPneumothorax::Copy(const SETensionPneumothorax& src) +void SETensionPneumothorax::Copy(const SETensionPneumothorax& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SETensionPneumothorax::IsValid() const @@ -40,7 +42,21 @@ bool SETensionPneumothorax::IsValid() const bool SETensionPneumothorax::IsActive() const { - return IsValid() ? !m_Severity->IsZero() : false; + if (!SEPatientAction::IsActive()) + return false; + return !m_Severity->IsZero(); +} +void SETensionPneumothorax::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SETensionPneumothorax::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; } eGate SETensionPneumothorax::GetType() const diff --git a/src/cpp/cdm/patient/actions/SETensionPneumothorax.h b/src/cpp/cdm/patient/actions/SETensionPneumothorax.h index 7a90f91a4bd0bdca9ea7b432bc0c4bf98885e0d8..3a2db298734121e2195f413192ee3295b68fe780 100644 --- a/src/cpp/cdm/patient/actions/SETensionPneumothorax.h +++ b/src/cpp/cdm/patient/actions/SETensionPneumothorax.h @@ -13,10 +13,11 @@ public: virtual ~SETensionPneumothorax(); virtual void Clear(); //clear memory - virtual void Copy(const SETensionPneumothorax& src); + virtual void Copy(const SETensionPneumothorax& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual eGate GetType() const; virtual void SetType(eGate name); @@ -34,6 +35,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: eGate m_Type; eSide m_Side; diff --git a/src/cpp/cdm/patient/actions/SEUrinate.cpp b/src/cpp/cdm/patient/actions/SEUrinate.cpp index fedfcc78862fe63d7a213a2aaedefed67b3f039f..b58b2589388bcf27bac7fd14ca0f1300b032eb5c 100644 --- a/src/cpp/cdm/patient/actions/SEUrinate.cpp +++ b/src/cpp/cdm/patient/actions/SEUrinate.cpp @@ -20,9 +20,11 @@ void SEUrinate::Clear() SEPatientAction::Clear(); } -void SEUrinate::Copy(const SEUrinate& src) +void SEUrinate::Copy(const SEUrinate& src, bool preserveState) { + //if(preserveState) // Cache any state before copy, PBPatientAction::Copy(src, *this); + //if(preserveState) // Put back any state } bool SEUrinate::IsValid() const @@ -32,7 +34,17 @@ bool SEUrinate::IsValid() const bool SEUrinate::IsActive() const { - return IsValid(); + return SEPatientAction::IsActive(); +} +void SEUrinate::Deactivate() +{ + SEPatientAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEUrinate::GetScalar(const std::string& name) +{ + return nullptr; } void SEUrinate::ToString(std::ostream &str) const diff --git a/src/cpp/cdm/patient/actions/SEUrinate.h b/src/cpp/cdm/patient/actions/SEUrinate.h index 2e2fd9472edb135b38d90c752ef425548553a915..eb18182556cc337f71ed594f339bdc97a3816a0a 100644 --- a/src/cpp/cdm/patient/actions/SEUrinate.h +++ b/src/cpp/cdm/patient/actions/SEUrinate.h @@ -13,13 +13,16 @@ public: virtual ~SEUrinate(); virtual void Clear(); //clear memory - virtual void Copy(const SEUrinate& src); + virtual void Copy(const SEUrinate& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: }; diff --git a/src/cpp/cdm/patient/conditions/SEChronicHeartFailure.cpp b/src/cpp/cdm/patient/conditions/SEChronicHeartFailure.cpp deleted file mode 100644 index 5e75e4b48be9f68eb4f7853e666d03d66b997e3b..0000000000000000000000000000000000000000 --- a/src/cpp/cdm/patient/conditions/SEChronicHeartFailure.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* Distributed under the Apache License, Version 2.0. - See accompanying NOTICE file for details.*/ - -#include "stdafx.h" -#include "patient/conditions/SEChronicHeartFailure.h" - -SEChronicHeartFailure::SEChronicHeartFailure(Logger* logger) : SEPatientCondition(logger) -{ -} - -SEChronicHeartFailure::~SEChronicHeartFailure() -{ - Clear(); -} - -void SEChronicHeartFailure::Clear() -{ - SEPatientCondition::Clear(); -} \ No newline at end of file diff --git a/src/cpp/cdm/patient/conditions/SEChronicHeartFailure.h b/src/cpp/cdm/patient/conditions/SEChronicHeartFailure.h deleted file mode 100644 index e34c0f73b9286a3c826da6cf81c5ed231c63b710..0000000000000000000000000000000000000000 --- a/src/cpp/cdm/patient/conditions/SEChronicHeartFailure.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Distributed under the Apache License, Version 2.0. - See accompanying NOTICE file for details.*/ - -#pragma once -#include "patient/conditions/SEPatientCondition.h" - -class CDM_DECL SEChronicHeartFailure : public SEPatientCondition -{ - friend class PBPatientCondition;//friend the serialization class -public: - - SEChronicHeartFailure(Logger* logger=nullptr); - virtual ~SEChronicHeartFailure(); - - virtual void Clear(); //clear memory - - virtual bool IsValid() const = 0; - virtual bool IsActive() const = 0; - -public: - virtual void ToString(std::ostream &str) const = 0; - -protected: -}; \ No newline at end of file diff --git a/src/cpp/cdm/patient/conditions/SEChronicVentricularSystolicDysfunction.cpp b/src/cpp/cdm/patient/conditions/SEChronicVentricularSystolicDysfunction.cpp index ad9e6e29325d012ad0ab75efbb0858fb5fb9c21d..8bef7a6ec17cca0e18efd9760ba1d6c782f50d0e 100644 --- a/src/cpp/cdm/patient/conditions/SEChronicVentricularSystolicDysfunction.cpp +++ b/src/cpp/cdm/patient/conditions/SEChronicVentricularSystolicDysfunction.cpp @@ -5,7 +5,7 @@ #include "patient/conditions/SEChronicVentricularSystolicDysfunction.h" #include "io/protobuf/PBPatientConditions.h" -SEChronicVentricularSystolicDysfunction::SEChronicVentricularSystolicDysfunction(Logger* logger) : SEChronicHeartFailure(logger) +SEChronicVentricularSystolicDysfunction::SEChronicVentricularSystolicDysfunction(Logger* logger) : SEPatientCondition(logger) { } @@ -16,7 +16,7 @@ SEChronicVentricularSystolicDysfunction::~SEChronicVentricularSystolicDysfunctio void SEChronicVentricularSystolicDysfunction::Clear() { - SEChronicHeartFailure::Clear(); + SEPatientCondition::Clear(); } void SEChronicVentricularSystolicDysfunction::Copy(const SEChronicVentricularSystolicDysfunction& src) diff --git a/src/cpp/cdm/patient/conditions/SEChronicVentricularSystolicDysfunction.h b/src/cpp/cdm/patient/conditions/SEChronicVentricularSystolicDysfunction.h index cedff2ad4fb8101990187301c4a7faa0ce4da084..d5e7fd1dbe349b0ec5eb3a61c7e685730b86d648 100644 --- a/src/cpp/cdm/patient/conditions/SEChronicVentricularSystolicDysfunction.h +++ b/src/cpp/cdm/patient/conditions/SEChronicVentricularSystolicDysfunction.h @@ -2,9 +2,9 @@ See accompanying NOTICE file for details.*/ #pragma once -#include "patient/conditions/SEChronicHeartFailure.h" +#include "patient/conditions/SEPatientCondition.h" -class CDM_DECL SEChronicVentricularSystolicDysfunction : public SEChronicHeartFailure +class CDM_DECL SEChronicVentricularSystolicDysfunction : public SEPatientCondition { friend class PBPatientCondition;//friend the serialization class public: diff --git a/src/cpp/cdm/properties/SEScalar.cpp b/src/cpp/cdm/properties/SEScalar.cpp index 8d76924b1de05b807a8500f7c96febc659784a47..bfa5c96b542e52252251cc881e9ed342628cdf91 100644 --- a/src/cpp/cdm/properties/SEScalar.cpp +++ b/src/cpp/cdm/properties/SEScalar.cpp @@ -55,8 +55,8 @@ void SEScalar::Clear() bool SEScalar::Set(const SEScalar& s) { if (dynamic_cast(&s) != nullptr) - std::cerr << " HALT "; - if(!s.IsValid()) + throw CommonDataModelException("Scalar is not of the proper type"); + if(!s.IsValid()) return false; if (m_readOnly) throw CommonDataModelException("Scalar is marked read-only"); @@ -242,6 +242,10 @@ bool SEScalar::IsZero(double d, double limit) return false; } +////////////////////// +// SEScalarQuantity // +////////////////////// + template SEScalarQuantity::SEScalarQuantity() : SEUnitScalar() { diff --git a/src/cpp/cdm/properties/SEScalar.h b/src/cpp/cdm/properties/SEScalar.h index 018a0d8703b4d44f7e7d88e97504385879da00f1..6b343f350f35ae5a4af4bf8639427dcdf2c59331 100644 --- a/src/cpp/cdm/properties/SEScalar.h +++ b/src/cpp/cdm/properties/SEScalar.h @@ -113,6 +113,58 @@ inline std::ostream& operator<< (std::ostream& out, const SEScalar& s) return out; } +template +class CDM_DECL SEScalarEnum : public SEScalar +{ +public: + SEScalarEnum() : SEScalar() { Clear(); } + virtual ~SEScalarEnum() { Clear(); } + + virtual void Invalidate() + { + SEScalar::Invalidate(); + m_enum = (Enum)-1; + } + bool Set(const SEScalarEnum& s) + { + SEScalar::Set(s); + m_enum = s.m_enum; + } + void Copy(const SEScalarEnum& s) + { + SEScalar::Set(s); + m_enum = s.m_enum; + } + + Enum GetEnum() const { return m_enum; } + void SetEnum(Enum e) + { + m_enum = e; + SetValue((double)e); + } + +private: + using SEScalar::IsInfinity; + + using SEScalar::IsPositive; + using SEScalar::IsNegative; + using SEScalar::IsZero; + + using SEScalar::SetValue; + using SEScalar::ForceValue; + + using SEScalar::Increment; + using SEScalar::IncrementValue; + + using SEScalar::Multiply; + using SEScalar::MultiplyValue; + + using SEScalar::Average; + +protected: + Enum m_enum; +}; + /** * @brief - An interface to be used for gaining access to a scalar with any unit type * @details - This interface allows you to have a pointer to a scalar with units @@ -349,4 +401,3 @@ inline void IncrementOverride(SEScalarQuantity& s, double value, const Uni double Get##name(const type##Unit& unit) const { return m_##name.GetValue(unit); } \ protected: \ SEScalar##type m_##name; - diff --git a/src/cpp/cdm/substance/SESubstanceCompound.cpp b/src/cpp/cdm/substance/SESubstanceCompound.cpp index e63d346a8d8affe55e23a2ee2ea7a09227f9ce5f..ea49428a61f0252c8f0e6d8d7bc761184c8d177c 100644 --- a/src/cpp/cdm/substance/SESubstanceCompound.cpp +++ b/src/cpp/cdm/substance/SESubstanceCompound.cpp @@ -68,7 +68,7 @@ const std::vector& SESubstanceCompound::GetComp { return m_cComponents; } -const SESubstanceConcentration& SESubstanceCompound::GetComponent(SESubstance& substance) +SESubstanceConcentration& SESubstanceCompound::GetComponent(const SESubstance& substance) { for (SESubstanceConcentration* sq : m_Components) { @@ -81,7 +81,7 @@ const SESubstanceConcentration& SESubstanceCompound::GetComponent(SESubstance& s m_cComponents.push_back(sq); return *sq; } -const SESubstanceConcentration* SESubstanceCompound::GetComponent(SESubstance& substance) const +const SESubstanceConcentration* SESubstanceCompound::GetComponent(const SESubstance& substance) const { for (SESubstanceConcentration* sq : m_Components) { @@ -100,6 +100,7 @@ void SESubstanceCompound::RemoveComponent(const SESubstance& substance) m_Components.erase(m_Components.begin() + i); m_cComponents.erase(m_cComponents.begin() + i); delete sq; + break; } i++; } diff --git a/src/cpp/cdm/substance/SESubstanceCompound.h b/src/cpp/cdm/substance/SESubstanceCompound.h index 915e0b142c73b03f145f7a06397ba7a80a9d7566..17f927076ccf5bbba636ad180942c180a1b24477 100644 --- a/src/cpp/cdm/substance/SESubstanceCompound.h +++ b/src/cpp/cdm/substance/SESubstanceCompound.h @@ -26,10 +26,10 @@ public: bool HasComponent() const; bool HasComponent(const SESubstance& substance) const; - const std::vector& GetComponents(); + const std::vector& GetComponents(); const std::vector& GetComponents() const; - const SESubstanceConcentration& GetComponent(SESubstance& substance); - const SESubstanceConcentration* GetComponent(SESubstance& substance) const; + SESubstanceConcentration& GetComponent(const SESubstance& substance); + const SESubstanceConcentration* GetComponent(const SESubstance& substance) const; void RemoveComponent(const SESubstance& substance); protected: diff --git a/src/cpp/cdm/system/environment/SEEnvironment.cpp b/src/cpp/cdm/system/environment/SEEnvironment.cpp index 3f8c61b887fe1938ad281483e4f6dfcb4765fd15..6e9a8766af85ad4493db5ffb7c1743f23d344164 100644 --- a/src/cpp/cdm/system/environment/SEEnvironment.cpp +++ b/src/cpp/cdm/system/environment/SEEnvironment.cpp @@ -134,9 +134,7 @@ bool SEEnvironment::ProcessChange(SEChangeEnvironmentalConditions& change, SESub { // If we have data then we merge it, if a file was provided // we reset and set the environment to the file, so we only have the file data - if (change.HasEnvironmentalConditions()) - GetEnvironmentalConditions().Merge(change.GetEnvironmentalConditions(), subMgr); - else if (change.HasEnvironmentalConditionsFile()) + if (change.HasEnvironmentalConditionsFile()) { // Update the action with the file contents std::string cfg_file = change.GetEnvironmentalConditionsFile(); @@ -148,6 +146,8 @@ bool SEEnvironment::ProcessChange(SEChangeEnvironmentalConditions& change, SESub } GetEnvironmentalConditions().Merge(change.GetEnvironmentalConditions(), subMgr); } + else if (change.HasEnvironmentalConditions()) + GetEnvironmentalConditions().Merge(change.GetEnvironmentalConditions(), subMgr); StateChange(); return true; } diff --git a/src/cpp/cdm/system/environment/SEEnvironmentalConditions.cpp b/src/cpp/cdm/system/environment/SEEnvironmentalConditions.cpp index d7afda69bdb2c0563449368d0c38c99ef93b6293..fa58790013ed73e3952019b1ba8f0ca800707e6d 100644 --- a/src/cpp/cdm/system/environment/SEEnvironmentalConditions.cpp +++ b/src/cpp/cdm/system/environment/SEEnvironmentalConditions.cpp @@ -329,14 +329,19 @@ double SEEnvironmentalConditions::GetRespirationAmbientTemperature(const Tempera bool SEEnvironmentalConditions::HasAmbientGas() const { - return m_AmbientGases.size() == 0 ? false : true; + if (m_AmbientGases.empty()) + return false; + for (auto g : m_AmbientGases) + if (g->HasFractionAmount() && g->GetFractionAmount().IsPositive()) + return true; + return false; } bool SEEnvironmentalConditions::HasAmbientGas(const SESubstance& s) const { for (const SESubstanceFraction* sf : m_AmbientGases) { if (&s == &sf->GetSubstance()) - return sf->GetFractionAmount() > 0; + return sf->HasFractionAmount() && sf->GetFractionAmount() > 0; } return false; } @@ -385,14 +390,19 @@ void SEEnvironmentalConditions::RemoveAmbientGases() bool SEEnvironmentalConditions::HasAmbientAerosol() const { - return m_AmbientAerosols.size() == 0 ? false : true; + if (m_AmbientAerosols.empty()) + return false; + for (auto a : m_AmbientAerosols) + if (a->HasConcentration() && a->GetConcentration().IsPositive()) + return true; + return false; } bool SEEnvironmentalConditions::HasAmbientAerosol(const SESubstance& substance) const { for (SESubstanceConcentration* sc : m_AmbientAerosols) { if (&substance == &sc->GetSubstance()) - return sc->GetConcentration().IsPositive(); + return sc->HasConcentration() && sc->GetConcentration().IsPositive(); } return false; } diff --git a/src/cpp/cdm/system/environment/actions/SEChangeEnvironmentalConditions.cpp b/src/cpp/cdm/system/environment/actions/SEChangeEnvironmentalConditions.cpp index 8425fb6a73bffac73c1f0a7710182a12c59d63e8..b82ecdfcbf9841e2ecdcaba6deecd1138f4b8376 100644 --- a/src/cpp/cdm/system/environment/actions/SEChangeEnvironmentalConditions.cpp +++ b/src/cpp/cdm/system/environment/actions/SEChangeEnvironmentalConditions.cpp @@ -39,7 +39,7 @@ void SEChangeEnvironmentalConditions::Clear() m_EnvironmentalConditions->Clear(); } -void SEChangeEnvironmentalConditions::Copy(const SEChangeEnvironmentalConditions& src, const SESubstanceManager& subMgr) +void SEChangeEnvironmentalConditions::Copy(const SEChangeEnvironmentalConditions& src, const SESubstanceManager& subMgr, bool preserveState) {// Using Bindings to make a copy PBEnvironmentAction::Copy(src, *this, subMgr); } @@ -49,6 +49,21 @@ bool SEChangeEnvironmentalConditions::IsValid() const return SEEnvironmentAction::IsValid() && (HasEnvironmentalConditions() || HasEnvironmentalConditionsFile()); } +bool SEChangeEnvironmentalConditions::IsActive() const +{ + return SEEnvironmentAction::IsActive(); +} +void SEChangeEnvironmentalConditions::Deactivate() +{ + SEEnvironmentAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEChangeEnvironmentalConditions::GetScalar(const std::string& name) +{ + return GetEnvironmentalConditions().GetScalar(name); +} + bool SEChangeEnvironmentalConditions::HasEnvironmentalConditions() const { return m_EnvironmentalConditions != nullptr; diff --git a/src/cpp/cdm/system/environment/actions/SEChangeEnvironmentalConditions.h b/src/cpp/cdm/system/environment/actions/SEChangeEnvironmentalConditions.h index 522ee6cd86ad21b9f9329daed871a1c91d8538ef..2b5e0d0e21b205f57a788bc894c1ead55356c6cc 100644 --- a/src/cpp/cdm/system/environment/actions/SEChangeEnvironmentalConditions.h +++ b/src/cpp/cdm/system/environment/actions/SEChangeEnvironmentalConditions.h @@ -14,9 +14,11 @@ public: virtual ~SEChangeEnvironmentalConditions(); virtual void Clear(); - virtual void Copy(const SEChangeEnvironmentalConditions& src, const SESubstanceManager& subMgr); + virtual void Copy(const SEChangeEnvironmentalConditions& src, const SESubstanceManager& subMgr, bool preserveState=false); virtual bool IsValid() const; + virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasEnvironmentalConditions() const; virtual SEEnvironmentalConditions& GetEnvironmentalConditions(); @@ -28,6 +30,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: std::string m_EnvironmentalConditionsFile; diff --git a/src/cpp/cdm/system/environment/actions/SEThermalApplication.cpp b/src/cpp/cdm/system/environment/actions/SEThermalApplication.cpp index 2103099248e48614cc2999f196627e6e5324d800..606e354a4f63f7d0c11f34bc57b1185041cb1e27 100644 --- a/src/cpp/cdm/system/environment/actions/SEThermalApplication.cpp +++ b/src/cpp/cdm/system/environment/actions/SEThermalApplication.cpp @@ -39,7 +39,7 @@ void SEThermalApplication::Clear() } } -void SEThermalApplication::Copy(const SEThermalApplication& src) +void SEThermalApplication::Copy(const SEThermalApplication& src, bool preserveState) {// Using Bindings to make a copy PBEnvironmentAction::Copy(src, *this); } @@ -51,6 +51,8 @@ bool SEThermalApplication::IsValid() const bool SEThermalApplication::IsActive() const { + if (!SEEnvironmentAction::IsActive()) + return false; if (HasActiveHeating() && m_ActiveHeating->GetPower().IsPositive()) return true; if (HasActiveCooling() && m_ActiveCooling->GetPower().IsPositive()) @@ -60,6 +62,29 @@ bool SEThermalApplication::IsActive() const return false; } +void SEThermalApplication::Deactivate() +{ + SEEnvironmentAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEThermalApplication::GetScalar(const std::string& name) +{ + size_t split = name.find('-'); + if (split != name.npos) + { + std::string child = name.substr(0, split); + std::string prop = name.substr(split + 1, name.npos); + if (child == "ActiveHeating") + return GetActiveHeating().GetScalar(prop); + if (child == "ActiveCooling") + return GetActiveCooling().GetScalar(prop); + if (child == "AppliedTemperature") + return GetAppliedTemperature().GetScalar(prop); + } + return nullptr; +} + bool SEThermalApplication::HasActiveHeating() const { if (m_ActiveHeating == nullptr) diff --git a/src/cpp/cdm/system/environment/actions/SEThermalApplication.h b/src/cpp/cdm/system/environment/actions/SEThermalApplication.h index 10666b7cafc5a58f4333b93c4e3dae2bdb9cef31..1731d5b1d028990427e682fffbf44a59d7b35de8 100644 --- a/src/cpp/cdm/system/environment/actions/SEThermalApplication.h +++ b/src/cpp/cdm/system/environment/actions/SEThermalApplication.h @@ -14,10 +14,11 @@ public: virtual ~SEThermalApplication(); virtual void Clear(); - virtual void Copy(const SEThermalApplication& src); + virtual void Copy(const SEThermalApplication& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasActiveHeating() const; virtual SEActiveConditioning& GetActiveHeating(); @@ -34,7 +35,9 @@ public: virtual const SEAppliedTemperature* GetAppliedTemperature() const; virtual void RemoveAppliedTemperature(); - virtual void ToString(std::ostream &str) const; + virtual void ToString(std::ostream& str) const; + + virtual const SEScalar* GetScalar(const std::string& name); protected: bool m_ClearContents; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineConfiguration.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineConfiguration.cpp index 47d379e364073bf9cd1322ba4eb9c377a4bf0439..26e5c3cf2f2163c6f37973d9ce0a163241c9c13f 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineConfiguration.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineConfiguration.cpp @@ -34,7 +34,7 @@ void SEAnesthesiaMachineConfiguration::Clear() m_Configuration->Clear(); } -void SEAnesthesiaMachineConfiguration::Copy(const SEAnesthesiaMachineConfiguration& src, const SESubstanceManager& subMgr) +void SEAnesthesiaMachineConfiguration::Copy(const SEAnesthesiaMachineConfiguration& src, const SESubstanceManager& subMgr, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this, subMgr); } @@ -44,6 +44,21 @@ bool SEAnesthesiaMachineConfiguration::IsValid() const return SEAnesthesiaMachineAction::IsValid() && (HasConfiguration() || HasConfigurationFile()); } +bool SEAnesthesiaMachineConfiguration::IsActive() const +{ + return SEAnesthesiaMachineAction::IsActive(); +} +void SEAnesthesiaMachineConfiguration::Deactivate() +{ + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineConfiguration::GetScalar(const std::string& name) +{ + return GetConfiguration().GetScalar(name); +} + bool SEAnesthesiaMachineConfiguration::HasConfiguration() const { return m_Configuration != nullptr; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineConfiguration.h b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineConfiguration.h index efb431f08bf72582d9df3da4ddce907c919c3f71..bc60886c7b6ac476c7c7d845fedd18ab5883137a 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineConfiguration.h +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineConfiguration.h @@ -14,9 +14,11 @@ public: virtual ~SEAnesthesiaMachineConfiguration(); virtual void Clear(); - virtual void Copy(const SEAnesthesiaMachineConfiguration& src, const SESubstanceManager& subMgr); + virtual void Copy(const SEAnesthesiaMachineConfiguration& src, const SESubstanceManager& subMgr, bool preserveState=false); virtual bool IsValid() const; + virtual bool IsActive() const; + virtual void Deactivate(); bool HasConfiguration() const; SEAnesthesiaMachine& GetConfiguration(); @@ -28,6 +30,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: std::string m_ConfigurationFile; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveLeak.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveLeak.cpp index b2ec51f44c3a9ad8e6561a69bf42baf662662d88..cc003236b26d04c1a18d6a5a96743b24d10994c2 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveLeak.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveLeak.cpp @@ -21,7 +21,7 @@ void SEAnesthesiaMachineExpiratoryValveLeak::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAnesthesiaMachineExpiratoryValveLeak::Copy(const SEAnesthesiaMachineExpiratoryValveLeak& src) +void SEAnesthesiaMachineExpiratoryValveLeak::Copy(const SEAnesthesiaMachineExpiratoryValveLeak& src, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this); } @@ -33,9 +33,24 @@ bool SEAnesthesiaMachineExpiratoryValveLeak::IsValid() const bool SEAnesthesiaMachineExpiratoryValveLeak::IsActive() const { + if (!SEAnesthesiaMachineAction::IsActive()) + return false; return HasSeverity() ? !m_Severity->IsZero() : false; } +void SEAnesthesiaMachineExpiratoryValveLeak::Deactivate() +{ + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineExpiratoryValveLeak::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; +} + bool SEAnesthesiaMachineExpiratoryValveLeak::HasSeverity() const { return m_Severity != nullptr; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveLeak.h b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveLeak.h index 7947b9beb9e13c55dee179300bc7dc4f06800d13..95e039d56f84e46afc26d8bc090aecb4770a4479 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveLeak.h +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveLeak.h @@ -12,10 +12,11 @@ public: virtual ~SEAnesthesiaMachineExpiratoryValveLeak(); virtual void Clear(); - virtual void Copy(const SEAnesthesiaMachineExpiratoryValveLeak& src); + virtual void Copy(const SEAnesthesiaMachineExpiratoryValveLeak& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -23,6 +24,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveObstruction.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveObstruction.cpp index ea067b517c2b68942993f51ea5f567d69485fb64..72648200e3d07d1d5412cd4ac09119324b02e930 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveObstruction.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveObstruction.cpp @@ -21,7 +21,7 @@ void SEAnesthesiaMachineExpiratoryValveObstruction::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAnesthesiaMachineExpiratoryValveObstruction::Copy(const SEAnesthesiaMachineExpiratoryValveObstruction& src) +void SEAnesthesiaMachineExpiratoryValveObstruction::Copy(const SEAnesthesiaMachineExpiratoryValveObstruction& src, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this); } @@ -33,8 +33,22 @@ bool SEAnesthesiaMachineExpiratoryValveObstruction::IsValid() const bool SEAnesthesiaMachineExpiratoryValveObstruction::IsActive() const { + if (!SEAnesthesiaMachineAction::IsActive()) + return false; return HasSeverity() ? !m_Severity->IsZero() : false; } +void SEAnesthesiaMachineExpiratoryValveObstruction::Deactivate() +{ + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineExpiratoryValveObstruction::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; +} bool SEAnesthesiaMachineExpiratoryValveObstruction::HasSeverity() const { diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveObstruction.h b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveObstruction.h index f420011cbb08ff29927e2da82411b022f5d64c4d..65782fe2da66b3fead0e2d8abdd4f3fa94ef751d 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveObstruction.h +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineExpiratoryValveObstruction.h @@ -12,10 +12,11 @@ public: virtual ~SEAnesthesiaMachineExpiratoryValveObstruction(); virtual void Clear(); - virtual void Copy(const SEAnesthesiaMachineExpiratoryValveObstruction& src); + virtual void Copy(const SEAnesthesiaMachineExpiratoryValveObstruction& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -23,6 +24,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveLeak.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveLeak.cpp index 1a93e0965f746ad694be9039b25eb24670b63a45..172cc2515c6c9b738c49e44e88910af7f1189ec7 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveLeak.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveLeak.cpp @@ -21,7 +21,7 @@ void SEAnesthesiaMachineInspiratoryValveLeak::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAnesthesiaMachineInspiratoryValveLeak::Copy(const SEAnesthesiaMachineInspiratoryValveLeak& src) +void SEAnesthesiaMachineInspiratoryValveLeak::Copy(const SEAnesthesiaMachineInspiratoryValveLeak& src, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this); } @@ -33,8 +33,22 @@ bool SEAnesthesiaMachineInspiratoryValveLeak::IsValid() const bool SEAnesthesiaMachineInspiratoryValveLeak::IsActive() const { + if (!SEAnesthesiaMachineAction::IsActive()) + return false; return HasSeverity() ? !m_Severity->IsZero() : false; } +void SEAnesthesiaMachineInspiratoryValveLeak::Deactivate() +{ + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineInspiratoryValveLeak::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; +} bool SEAnesthesiaMachineInspiratoryValveLeak::HasSeverity() const { diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveLeak.h b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveLeak.h index 63fd4331cc52aa4bf7d0d63aa8dbd02be116d6ae..d68019376fe4ceae59c14e9f69b1a212ac788076 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveLeak.h +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveLeak.h @@ -12,10 +12,11 @@ public: virtual ~SEAnesthesiaMachineInspiratoryValveLeak(); virtual void Clear(); - virtual void Copy(const SEAnesthesiaMachineInspiratoryValveLeak& src); + virtual void Copy(const SEAnesthesiaMachineInspiratoryValveLeak& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -23,6 +24,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveObstruction.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveObstruction.cpp index 224414c09d6b08824d71f11e12b5c9cdf8d3ae1f..a68f80618c1f2807521de9df174cdc763ad46851 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveObstruction.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveObstruction.cpp @@ -21,7 +21,7 @@ void SEAnesthesiaMachineInspiratoryValveObstruction::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAnesthesiaMachineInspiratoryValveObstruction::Copy(const SEAnesthesiaMachineInspiratoryValveObstruction& src) +void SEAnesthesiaMachineInspiratoryValveObstruction::Copy(const SEAnesthesiaMachineInspiratoryValveObstruction& src, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this); } @@ -33,8 +33,22 @@ bool SEAnesthesiaMachineInspiratoryValveObstruction::IsValid() const bool SEAnesthesiaMachineInspiratoryValveObstruction::IsActive() const { + if (!SEAnesthesiaMachineAction::IsActive()) + return false; return HasSeverity() ? !m_Severity->IsZero() : false; } +void SEAnesthesiaMachineInspiratoryValveObstruction::Deactivate() +{ + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineInspiratoryValveObstruction::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; +} bool SEAnesthesiaMachineInspiratoryValveObstruction::HasSeverity() const { diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveObstruction.h b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveObstruction.h index f329acd98c4f3353404c33daea9766ea6240958a..a8125c10fc449f433189627f2d5cd7c59c5802ed 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveObstruction.h +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineInspiratoryValveObstruction.h @@ -12,10 +12,11 @@ public: virtual ~SEAnesthesiaMachineInspiratoryValveObstruction(); virtual void Clear(); - virtual void Copy(const SEAnesthesiaMachineInspiratoryValveObstruction& src); + virtual void Copy(const SEAnesthesiaMachineInspiratoryValveObstruction& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -23,6 +24,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineMaskLeak.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineMaskLeak.cpp index 2e32942a6d062d347bbe4ee8e5ffce02fc44fadd..ebd1ab1536cd11b55b1568427c6615401f0fc0b6 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineMaskLeak.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineMaskLeak.cpp @@ -21,7 +21,7 @@ void SEAnesthesiaMachineMaskLeak::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAnesthesiaMachineMaskLeak::Copy(const SEAnesthesiaMachineMaskLeak& src) +void SEAnesthesiaMachineMaskLeak::Copy(const SEAnesthesiaMachineMaskLeak& src, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this); } @@ -33,8 +33,22 @@ bool SEAnesthesiaMachineMaskLeak::IsValid() const bool SEAnesthesiaMachineMaskLeak::IsActive() const { + if (!SEAnesthesiaMachineAction::IsActive()) + return false; return HasSeverity() ? !m_Severity->IsZero() : false; } +void SEAnesthesiaMachineMaskLeak::Deactivate() +{ + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineMaskLeak::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; +} bool SEAnesthesiaMachineMaskLeak::HasSeverity() const { diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineMaskLeak.h b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineMaskLeak.h index 77e33924dafe0ab326fe984d1ae297ef8ccbbec6..706140ba8e43ccdda112a922dc3dc40bab366c0c 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineMaskLeak.h +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineMaskLeak.h @@ -12,10 +12,11 @@ public: virtual ~SEAnesthesiaMachineMaskLeak(); virtual void Clear(); - virtual void Copy(const SEAnesthesiaMachineMaskLeak& src); + virtual void Copy(const SEAnesthesiaMachineMaskLeak& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -23,6 +24,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineOxygenTankPressureLoss.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineOxygenTankPressureLoss.cpp index 4bed3aaa699347b281358bf55ebfbb18c0e864a6..eca026f998823f9d2e8d0ce293271e9408dea163 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineOxygenTankPressureLoss.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineOxygenTankPressureLoss.cpp @@ -7,21 +7,21 @@ SEAnesthesiaMachineOxygenTankPressureLoss::SEAnesthesiaMachineOxygenTankPressureLoss(Logger* logger) : SEAnesthesiaMachineAction(logger) { - m_State = eSwitch::Off; + m_State.SetEnum(eSwitch::Off); } SEAnesthesiaMachineOxygenTankPressureLoss::~SEAnesthesiaMachineOxygenTankPressureLoss() { - m_State = eSwitch::Off; + m_State.SetEnum(eSwitch::Off); } void SEAnesthesiaMachineOxygenTankPressureLoss::Clear() { SEAnesthesiaMachineAction::Clear(); - m_State = eSwitch::Off; + m_State.SetEnum(eSwitch::Off); } -void SEAnesthesiaMachineOxygenTankPressureLoss::Copy(const SEAnesthesiaMachineOxygenTankPressureLoss& src) +void SEAnesthesiaMachineOxygenTankPressureLoss::Copy(const SEAnesthesiaMachineOxygenTankPressureLoss& src, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this); } @@ -32,11 +32,30 @@ bool SEAnesthesiaMachineOxygenTankPressureLoss::IsValid() const } bool SEAnesthesiaMachineOxygenTankPressureLoss::IsActive() const { - return m_State == eSwitch::On; + if (!SEAnesthesiaMachineAction::IsActive()) + return false; + return m_State.GetEnum() == eSwitch::On; } -void SEAnesthesiaMachineOxygenTankPressureLoss::SetActive(bool b) +void SEAnesthesiaMachineOxygenTankPressureLoss::Deactivate() { - m_State = b ? eSwitch::On : eSwitch::Off; + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineOxygenTankPressureLoss::GetScalar(const std::string& name) +{ + if (name.compare("State") == 0) + return &m_State; + return nullptr; +} + +eSwitch SEAnesthesiaMachineOxygenTankPressureLoss::GetState() const +{ + return m_State.GetEnum(); +} +void SEAnesthesiaMachineOxygenTankPressureLoss::SetState(eSwitch state) +{ + m_State.SetEnum(state); } void SEAnesthesiaMachineOxygenTankPressureLoss::ToString(std::ostream &str) const @@ -44,6 +63,6 @@ void SEAnesthesiaMachineOxygenTankPressureLoss::ToString(std::ostream &str) cons str << "Anesthesia Machine Action : Oxygen Tank Pressure Loss"; if(HasComment()) str<<"\n\tComment: "< m_State; +}; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineOxygenWallPortPressureLoss.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineOxygenWallPortPressureLoss.cpp index d90828e437e716cd091a1c20c48bb0bd29c64c45..c0f73abfa2d2aa7c9d265faa9f1379035074b919 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineOxygenWallPortPressureLoss.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineOxygenWallPortPressureLoss.cpp @@ -7,21 +7,21 @@ SEAnesthesiaMachineOxygenWallPortPressureLoss::SEAnesthesiaMachineOxygenWallPortPressureLoss(Logger* logger) : SEAnesthesiaMachineAction(logger) { - m_State = eSwitch::Off; + m_State.SetEnum(eSwitch::Off); } SEAnesthesiaMachineOxygenWallPortPressureLoss::~SEAnesthesiaMachineOxygenWallPortPressureLoss() { - m_State = eSwitch::Off; + m_State.SetEnum(eSwitch::Off); } void SEAnesthesiaMachineOxygenWallPortPressureLoss::Clear() { SEAnesthesiaMachineAction::Clear(); - m_State = eSwitch::Off; + m_State.SetEnum(eSwitch::Off); } -void SEAnesthesiaMachineOxygenWallPortPressureLoss::Copy(const SEAnesthesiaMachineOxygenWallPortPressureLoss& src) +void SEAnesthesiaMachineOxygenWallPortPressureLoss::Copy(const SEAnesthesiaMachineOxygenWallPortPressureLoss& src, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this); } @@ -32,11 +32,31 @@ bool SEAnesthesiaMachineOxygenWallPortPressureLoss::IsValid() const } bool SEAnesthesiaMachineOxygenWallPortPressureLoss::IsActive() const { - return m_State == eSwitch::On; + if (!SEAnesthesiaMachineAction::IsActive()) + return false; + return m_State.GetEnum() == eSwitch::On; } -void SEAnesthesiaMachineOxygenWallPortPressureLoss::SetActive(bool b) +void SEAnesthesiaMachineOxygenWallPortPressureLoss::Deactivate() { - m_State = b ? eSwitch::On : eSwitch::Off; + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineOxygenWallPortPressureLoss::GetScalar(const std::string& name) +{ + if (name.compare("State") == 0) + return &m_State; + return nullptr; +} + + +eSwitch SEAnesthesiaMachineOxygenWallPortPressureLoss::GetState() const +{ + return m_State.GetEnum(); +} +void SEAnesthesiaMachineOxygenWallPortPressureLoss::SetState(eSwitch state) +{ + m_State.SetEnum(state); } void SEAnesthesiaMachineOxygenWallPortPressureLoss::ToString(std::ostream &str) const @@ -44,6 +64,6 @@ void SEAnesthesiaMachineOxygenWallPortPressureLoss::ToString(std::ostream &str) str << "Anesthesia Machine Action : Oxygen Wall Port Pressure Loss"; if(HasComment()) str << "\n\tComment: " << m_Comment; - str << "\n\tState: " << eSwitch_Name(m_State); + str << "\n\tState: " << eSwitch_Name(m_State.GetEnum()); str << std::flush; } \ No newline at end of file diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineOxygenWallPortPressureLoss.h b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineOxygenWallPortPressureLoss.h index e482311e744685c59ac8a59dc90e730e331968c1..1880701c95d9f47e738de9bff530a63e7f1cb951 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineOxygenWallPortPressureLoss.h +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineOxygenWallPortPressureLoss.h @@ -2,6 +2,7 @@ See accompanying NOTICE file for details.*/ #pragma once #include "system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineAction.h" +#include "properties/SEScalar.h" class CDM_DECL SEAnesthesiaMachineOxygenWallPortPressureLoss : public SEAnesthesiaMachineAction { @@ -11,15 +12,20 @@ public: virtual ~SEAnesthesiaMachineOxygenWallPortPressureLoss(); virtual void Clear(); - virtual void Copy(const SEAnesthesiaMachineOxygenWallPortPressureLoss& src); + virtual void Copy(const SEAnesthesiaMachineOxygenWallPortPressureLoss& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; - virtual void SetActive(bool b); + virtual void Deactivate(); + + virtual eSwitch GetState() const; + virtual void SetState(eSwitch state); virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: - - eSwitch m_State; -}; \ No newline at end of file + + SEScalarEnum m_State; +}; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineSodaLimeFailure.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineSodaLimeFailure.cpp index 8373b1d0e501fff1ee5ec6c479e26c21f9f56344..c712f79494b0164817aae90dd5226ef2a2f57bf3 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineSodaLimeFailure.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineSodaLimeFailure.cpp @@ -21,7 +21,7 @@ void SEAnesthesiaMachineSodaLimeFailure::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAnesthesiaMachineSodaLimeFailure::Copy(const SEAnesthesiaMachineSodaLimeFailure& src) +void SEAnesthesiaMachineSodaLimeFailure::Copy(const SEAnesthesiaMachineSodaLimeFailure& src, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this); } @@ -33,8 +33,22 @@ bool SEAnesthesiaMachineSodaLimeFailure::IsValid() const bool SEAnesthesiaMachineSodaLimeFailure::IsActive() const { + if (!SEAnesthesiaMachineAction::IsActive()) + return false; return HasSeverity() ? !m_Severity->IsZero() : false; } +void SEAnesthesiaMachineSodaLimeFailure::Deactivate() +{ + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineSodaLimeFailure::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; +} bool SEAnesthesiaMachineSodaLimeFailure::HasSeverity() const { diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineSodaLimeFailure.h b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineSodaLimeFailure.h index 4f085f26dcc02f768c59caff6f0389388699c51c..2114e490ef205e8c7063773564dd7e2503b429e4 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineSodaLimeFailure.h +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineSodaLimeFailure.h @@ -12,10 +12,11 @@ public: virtual ~SEAnesthesiaMachineSodaLimeFailure(); virtual void Clear(); - virtual void Copy(const SEAnesthesiaMachineSodaLimeFailure& src); + virtual void Copy(const SEAnesthesiaMachineSodaLimeFailure& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -23,6 +24,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineTubeCuffLeak.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineTubeCuffLeak.cpp index 3b6c93f3b141821cc256c88017713b634e7928f1..094c2573261a84880d6e370e496cae5198e7d3ea 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineTubeCuffLeak.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineTubeCuffLeak.cpp @@ -21,7 +21,7 @@ void SEAnesthesiaMachineTubeCuffLeak::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAnesthesiaMachineTubeCuffLeak::Copy(const SEAnesthesiaMachineTubeCuffLeak& src) +void SEAnesthesiaMachineTubeCuffLeak::Copy(const SEAnesthesiaMachineTubeCuffLeak& src, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this); } @@ -33,8 +33,22 @@ bool SEAnesthesiaMachineTubeCuffLeak::IsValid() const bool SEAnesthesiaMachineTubeCuffLeak::IsActive() const { + if (!SEAnesthesiaMachineAction::IsActive()) + return false; return HasSeverity() ? !m_Severity->IsZero() : false; } +void SEAnesthesiaMachineTubeCuffLeak::Deactivate() +{ + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineTubeCuffLeak::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; +} bool SEAnesthesiaMachineTubeCuffLeak::HasSeverity() const { diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineTubeCuffLeak.h b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineTubeCuffLeak.h index 8115a414d86050f2f8fd62154e7b3e69e81abda5..ecc9e7e8605b7ebb31f5e7bb5a9b898a7fef03da 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineTubeCuffLeak.h +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineTubeCuffLeak.h @@ -12,10 +12,11 @@ public: virtual ~SEAnesthesiaMachineTubeCuffLeak(); virtual void Clear(); - virtual void Copy(const SEAnesthesiaMachineTubeCuffLeak& src); + virtual void Copy(const SEAnesthesiaMachineTubeCuffLeak& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -23,6 +24,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVaporizerFailure.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVaporizerFailure.cpp index 3a425cf66156d49779984c1a100d4c9275cb1f83..2b3d767f9423717bac07025bc99bd65a7ac61da7 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVaporizerFailure.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVaporizerFailure.cpp @@ -21,7 +21,7 @@ void SEAnesthesiaMachineVaporizerFailure::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAnesthesiaMachineVaporizerFailure::Copy(const SEAnesthesiaMachineVaporizerFailure& src) +void SEAnesthesiaMachineVaporizerFailure::Copy(const SEAnesthesiaMachineVaporizerFailure& src, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this); } @@ -33,8 +33,22 @@ bool SEAnesthesiaMachineVaporizerFailure::IsValid() const bool SEAnesthesiaMachineVaporizerFailure::IsActive() const { + if (!SEAnesthesiaMachineAction::IsActive()) + return false; return HasSeverity() ? !m_Severity->IsZero() : false; } +void SEAnesthesiaMachineVaporizerFailure::Deactivate() +{ + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineVaporizerFailure::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; +} bool SEAnesthesiaMachineVaporizerFailure::HasSeverity() const { diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVaporizerFailure.h b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVaporizerFailure.h index b629de0a6c30d113d2913c99eb6e83a38d046829..4623c46b69052ce56d6f4a4a8d1cb14a8aba3af1 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVaporizerFailure.h +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVaporizerFailure.h @@ -12,10 +12,11 @@ public: virtual ~SEAnesthesiaMachineVaporizerFailure(); virtual void Clear(); - virtual void Copy(const SEAnesthesiaMachineVaporizerFailure& src); + virtual void Copy(const SEAnesthesiaMachineVaporizerFailure& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -23,6 +24,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVentilatorPressureLoss.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVentilatorPressureLoss.cpp index d269ddaa5ee0c9f510ea3841af06cad69688b80f..a8942b8b97be27e1290994cbc77d08269b8fee54 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVentilatorPressureLoss.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVentilatorPressureLoss.cpp @@ -21,7 +21,7 @@ void SEAnesthesiaMachineVentilatorPressureLoss::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAnesthesiaMachineVentilatorPressureLoss::Copy(const SEAnesthesiaMachineVentilatorPressureLoss& src) +void SEAnesthesiaMachineVentilatorPressureLoss::Copy(const SEAnesthesiaMachineVentilatorPressureLoss& src, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this); } @@ -33,8 +33,22 @@ bool SEAnesthesiaMachineVentilatorPressureLoss::IsValid() const bool SEAnesthesiaMachineVentilatorPressureLoss::IsActive() const { + if (!SEAnesthesiaMachineAction::IsActive()) + return false; return HasSeverity() ? !m_Severity->IsZero() : false; } +void SEAnesthesiaMachineVentilatorPressureLoss::Deactivate() +{ + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineVentilatorPressureLoss::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; +} bool SEAnesthesiaMachineVentilatorPressureLoss::HasSeverity() const { diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVentilatorPressureLoss.h b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVentilatorPressureLoss.h index f0bea6056d8ebbadaf8d42f62bcc76bc92f257fc..75525ff0dc55183213db6a2d0c5ad20dc3ffcf81 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVentilatorPressureLoss.h +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineVentilatorPressureLoss.h @@ -12,10 +12,11 @@ public: virtual ~SEAnesthesiaMachineVentilatorPressureLoss(); virtual void Clear(); - virtual void Copy(const SEAnesthesiaMachineVentilatorPressureLoss& src); + virtual void Copy(const SEAnesthesiaMachineVentilatorPressureLoss& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -23,6 +24,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineYPieceDisconnect.cpp b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineYPieceDisconnect.cpp index c0b0740b40a28ffbb24c47cce0feb08e52458ed2..60737f8b2036ec6a7c354afae5a14f06c82d5f6e 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineYPieceDisconnect.cpp +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineYPieceDisconnect.cpp @@ -21,7 +21,7 @@ void SEAnesthesiaMachineYPieceDisconnect::Clear() INVALIDATE_PROPERTY(m_Severity); } -void SEAnesthesiaMachineYPieceDisconnect::Copy(const SEAnesthesiaMachineYPieceDisconnect& src) +void SEAnesthesiaMachineYPieceDisconnect::Copy(const SEAnesthesiaMachineYPieceDisconnect& src, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this); } @@ -33,8 +33,22 @@ bool SEAnesthesiaMachineYPieceDisconnect::IsValid() const bool SEAnesthesiaMachineYPieceDisconnect::IsActive() const { + if (!SEAnesthesiaMachineAction::IsActive()) + return false; return HasSeverity() ? !m_Severity->IsZero() : false; } +void SEAnesthesiaMachineYPieceDisconnect::Deactivate() +{ + SEAnesthesiaMachineAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEAnesthesiaMachineYPieceDisconnect::GetScalar(const std::string& name) +{ + if (name.compare("Severity") == 0) + return &GetSeverity(); + return nullptr; +} bool SEAnesthesiaMachineYPieceDisconnect::HasSeverity() const { diff --git a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineYPieceDisconnect.h b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineYPieceDisconnect.h index 198ffa6357bcc54c693d4246ee892d3de40d56b2..0069ee6d355a08cf94412a3c0551964fa940f5c7 100644 --- a/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineYPieceDisconnect.h +++ b/src/cpp/cdm/system/equipment/anesthesia_machine/actions/SEAnesthesiaMachineYPieceDisconnect.h @@ -12,10 +12,11 @@ public: virtual ~SEAnesthesiaMachineYPieceDisconnect(); virtual void Clear(); - virtual void Copy(const SEAnesthesiaMachineYPieceDisconnect& src); + virtual void Copy(const SEAnesthesiaMachineYPieceDisconnect& src, bool preserveState=false); virtual bool IsValid() const; virtual bool IsActive() const; + virtual void Deactivate(); virtual bool HasSeverity() const; virtual SEScalar0To1& GetSeverity(); @@ -23,6 +24,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: SEScalar0To1* m_Severity; diff --git a/src/cpp/cdm/system/equipment/inhaler/actions/SEInhalerConfiguration.cpp b/src/cpp/cdm/system/equipment/inhaler/actions/SEInhalerConfiguration.cpp index c4282ee70f8a3199e4df07322efc30f5aa928536..c52881dd6f55bfd7657762eca3279adcc69c5759 100644 --- a/src/cpp/cdm/system/equipment/inhaler/actions/SEInhalerConfiguration.cpp +++ b/src/cpp/cdm/system/equipment/inhaler/actions/SEInhalerConfiguration.cpp @@ -30,7 +30,7 @@ void SEInhalerConfiguration::Clear() m_Configuration->Clear(); } -void SEInhalerConfiguration::Copy(const SEInhalerConfiguration& src, const SESubstanceManager& subMgr) +void SEInhalerConfiguration::Copy(const SEInhalerConfiguration& src, const SESubstanceManager& subMgr, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this, subMgr); } @@ -40,6 +40,21 @@ bool SEInhalerConfiguration::IsValid() const return SEInhalerAction::IsValid() && (HasConfiguration() || HasConfigurationFile()); } +bool SEInhalerConfiguration::IsActive() const +{ + return SEInhalerAction::IsActive(); +} +void SEInhalerConfiguration::Deactivate() +{ + SEInhalerAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEInhalerConfiguration::GetScalar(const std::string& name) +{ + return GetConfiguration().GetScalar(name); +} + bool SEInhalerConfiguration::HasConfiguration() const { return m_Configuration != nullptr; diff --git a/src/cpp/cdm/system/equipment/inhaler/actions/SEInhalerConfiguration.h b/src/cpp/cdm/system/equipment/inhaler/actions/SEInhalerConfiguration.h index b355db6ed9f2f57b241391972bc5335ede1b9613..7bf1371cc7d4c7ff1cb0f862798ebffa2892a854 100644 --- a/src/cpp/cdm/system/equipment/inhaler/actions/SEInhalerConfiguration.h +++ b/src/cpp/cdm/system/equipment/inhaler/actions/SEInhalerConfiguration.h @@ -14,9 +14,11 @@ public: virtual ~SEInhalerConfiguration(); virtual void Clear(); - virtual void Copy(const SEInhalerConfiguration& src, const SESubstanceManager& subMgr); - + virtual void Copy(const SEInhalerConfiguration& src, const SESubstanceManager& subMgr, bool preserveState = false); + virtual bool IsValid() const; + virtual bool IsActive() const; + virtual void Deactivate(); bool HasConfiguration() const; SEInhaler& GetConfiguration(); @@ -28,6 +30,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: std::string m_ConfigurationFile; diff --git a/src/cpp/cdm/system/equipment/mechanical_ventilator/SEMechanicalVentilator.cpp b/src/cpp/cdm/system/equipment/mechanical_ventilator/SEMechanicalVentilator.cpp index b99ecb82833dcf82e3dbe6b4e10f775d12753b63..6c8a219aec6d332dfce4385564b71cb76cea31d9 100644 --- a/src/cpp/cdm/system/equipment/mechanical_ventilator/SEMechanicalVentilator.cpp +++ b/src/cpp/cdm/system/equipment/mechanical_ventilator/SEMechanicalVentilator.cpp @@ -692,7 +692,12 @@ eMechanicalVentilator_DriverWaveform SEMechanicalVentilator::GetInspirationWavef bool SEMechanicalVentilator::HasFractionInspiredGas() const { - return m_FractionInspiredGases.size() == 0 ? false : true; + if (m_FractionInspiredGases.empty()) + return false; + for (auto a : m_FractionInspiredGases) + if (a->HasFractionAmount() && a->GetFractionAmount().IsPositive()) + return true; + return false; } bool SEMechanicalVentilator::HasFractionInspiredGas(const SESubstance& s) const { @@ -748,7 +753,12 @@ void SEMechanicalVentilator::RemoveFractionInspiredGases() bool SEMechanicalVentilator::HasConcentrationInspiredAerosol() const { - return m_ConcentrationInspiredAerosols.size() == 0 ? false : true; + if (m_ConcentrationInspiredAerosols.empty()) + return false; + for (auto a : m_ConcentrationInspiredAerosols) + if (a->HasConcentration() && a->GetConcentration().IsPositive()) + return true; + return false; } bool SEMechanicalVentilator::HasConcentrationInspiredAerosol(const SESubstance& substance) const { diff --git a/src/cpp/cdm/system/equipment/mechanical_ventilator/actions/SEMechanicalVentilatorConfiguration.cpp b/src/cpp/cdm/system/equipment/mechanical_ventilator/actions/SEMechanicalVentilatorConfiguration.cpp index 3f20b3e25efc30e08a61d0bb9de5bd55758398c6..aa368e79066d28ce26b3a053fe10b93b9f2e60d7 100644 --- a/src/cpp/cdm/system/equipment/mechanical_ventilator/actions/SEMechanicalVentilatorConfiguration.cpp +++ b/src/cpp/cdm/system/equipment/mechanical_ventilator/actions/SEMechanicalVentilatorConfiguration.cpp @@ -36,7 +36,7 @@ void SEMechanicalVentilatorConfiguration::Clear() m_Configuration->Clear(); } -void SEMechanicalVentilatorConfiguration::Copy(const SEMechanicalVentilatorConfiguration& src, const SESubstanceManager& subMgr) +void SEMechanicalVentilatorConfiguration::Copy(const SEMechanicalVentilatorConfiguration& src, const SESubstanceManager& subMgr, bool preserveState) {// Using Bindings to make a copy PBEquipmentAction::Copy(src, *this, subMgr); } @@ -46,6 +46,21 @@ bool SEMechanicalVentilatorConfiguration::IsValid() const return SEMechanicalVentilatorAction::IsValid() && (HasConfiguration() || HasConfigurationFile()); } +bool SEMechanicalVentilatorConfiguration::IsActive() const +{ + return SEMechanicalVentilatorAction::IsActive(); +} +void SEMechanicalVentilatorConfiguration::Deactivate() +{ + SEMechanicalVentilatorAction::Deactivate(); + Clear();//No stateful properties +} + +const SEScalar* SEMechanicalVentilatorConfiguration::GetScalar(const std::string& name) +{ + return GetConfiguration().GetScalar(name); +} + bool SEMechanicalVentilatorConfiguration::HasConfiguration() const { return m_Configuration != nullptr; diff --git a/src/cpp/cdm/system/equipment/mechanical_ventilator/actions/SEMechanicalVentilatorConfiguration.h b/src/cpp/cdm/system/equipment/mechanical_ventilator/actions/SEMechanicalVentilatorConfiguration.h index 6bd01fdb2cf252472b2cdb57f0a645a7b5b1df96..98cfd05fe85f67b9640a0c9a04e0ba815204505a 100644 --- a/src/cpp/cdm/system/equipment/mechanical_ventilator/actions/SEMechanicalVentilatorConfiguration.h +++ b/src/cpp/cdm/system/equipment/mechanical_ventilator/actions/SEMechanicalVentilatorConfiguration.h @@ -14,9 +14,11 @@ public: virtual ~SEMechanicalVentilatorConfiguration(); virtual void Clear(); - virtual void Copy(const SEMechanicalVentilatorConfiguration& src, const SESubstanceManager& subMgr); + virtual void Copy(const SEMechanicalVentilatorConfiguration& src, const SESubstanceManager& subMgr, bool preserveState = false); virtual bool IsValid() const; + virtual bool IsActive() const; + virtual void Deactivate(); bool HasConfiguration() const; SEMechanicalVentilator& GetConfiguration(); @@ -28,6 +30,8 @@ public: virtual void ToString(std::ostream &str) const; + virtual const SEScalar* GetScalar(const std::string& name); + protected: std::string m_ConfigurationFile; diff --git a/src/cpp/cpm/PulseScenarioExec.cpp b/src/cpp/cpm/PulseScenarioExec.cpp index 8cc890c0354cf90125969c11a3939a51a13ed929..ef08a3534926e3e9004e9315efd46ac1910d6e89 100644 --- a/src/cpp/cpm/PulseScenarioExec.cpp +++ b/src/cpp/cpm/PulseScenarioExec.cpp @@ -167,37 +167,33 @@ bool PulseScenarioExec::Execute(PhysiologyEngine& engine, const PulseScenario& s return success; } -bool PulseScenarioExec::ProcessActions(PulseEngine& engine, const SEScenario& scenario) +bool PulseScenarioExec::ProcessActions(PhysiologyEngine& engine, const SEScenario& scenario) { return SEScenarioExec::ProcessActions(engine, scenario); } -bool PulseScenarioExec::ProcessAction(PulseEngine& engine, const SEAction& action) +bool PulseScenarioExec::ProcessAction(PhysiologyEngine& engine, const SEAction& action) { - if (m_AutoSerializationAfterActions == eSwitch::On) + if (m_AutoSerializationAfterActions == eSwitch::On && m_AutoSerializationActions.str().empty()) { - m_ss << action; - size_t start = m_ss.str().find(": ") + 2; - size_t end = m_ss.str().find('\n'); - m_AutoSerializationActions << "-" << m_ss.str().substr(start, end - start); - m_ss.str(""); + m_AutoSerializationActions << "/AfterActions"; } return SEScenarioExec::ProcessAction(engine, action); } -void PulseScenarioExec::AdvanceEngine(PulseEngine& engine) +void PulseScenarioExec::AdvanceEngine(PhysiologyEngine& engine) { if (m_AutoSerializationPeriod_s > 0) { m_AutoSerializationTime_s += engine.GetTimeStep(TimeUnit::s); if (m_AutoSerializationTime_s >= m_AutoSerializationPeriod_s) { - Info("Serializing state after requested period : " + m_AutoSerializationActions.str()); m_AutoSerializationTime_s = 0; m_AutoSerializationOutput.str(""); m_AutoSerializationOutput << m_AutoSerializationDirectory <<"/"<< m_AutoSerializationFileName; if (m_AutoSerializationTimeStamps == eSwitch::On) - m_AutoSerializationOutput << "@" << engine.GetSimulationTime(TimeUnit::s); + m_AutoSerializationOutput << "/" << m_AutoSerializationFileName<< "@" << engine.GetSimulationTime(TimeUnit::s); engine.SerializeToFile(m_AutoSerializationOutput.str() + ".json"); + Info("Serializing state after requested period : " + m_AutoSerializationOutput.str() + ".json"); if (m_AutoSerializationReload == eSwitch::On) { engine.SerializeFromFile(m_AutoSerializationOutput.str() + ".json"); @@ -208,14 +204,15 @@ void PulseScenarioExec::AdvanceEngine(PulseEngine& engine) engine.AdvanceModelTime(); if (m_AutoSerializationActions.str().length() > 0) { - Info("Serializing state after actions : " + m_AutoSerializationActions.str()); m_AutoSerializationOutput.str(""); m_AutoSerializationOutput << m_AutoSerializationDirectory <<"/"<< m_AutoSerializationFileName<AddSystem(*m_BloodChemistrySystem); if (m_CardiovascularSystem) @@ -285,7 +285,7 @@ void PulseController::Allocate() m_SaturationCalculator = new SaturationCalculator(*this); - m_Actions = new SEActionManager(GetLogger()); + m_Actions = new SEActionManager(*m_Substances); m_Conditions = new SEConditionManager(GetLogger()); m_BloodChemistrySystem = new BloodChemistry(*this); @@ -807,7 +807,7 @@ bool PulseController::ProcessAction(const SEAction& action) return true; } - return GetActions().ProcessAction(action, *m_Substances); + return GetActions().ProcessAction(action); } bool PulseController::GetPatientAssessment(SEPatientAssessment& assessment) const diff --git a/src/cpp/cpm/environment/Environment.cpp b/src/cpp/cpm/environment/Environment.cpp index 21ff3373c980fdcd6ab0505e3cfcb27baf7e2dbd..484ec0862220af5fcbe7be030dbb2cdbe3cfecbf 100644 --- a/src/cpp/cpm/environment/Environment.cpp +++ b/src/cpp/cpm/environment/Environment.cpp @@ -153,7 +153,7 @@ void Environment::StateChange() if (m_AmbientGases == nullptr ||m_AmbientAerosols == nullptr) return; - if (GetEnvironmentalConditions().GetAmbientGases().size() > 0) + if (GetEnvironmentalConditions().HasAmbientGas()) { // Add Gases to the environment //Check to make sure fractions sum to 1.0 @@ -224,7 +224,7 @@ void Environment::PreProcess() { if (m_data.GetActions().GetEnvironmentActions().HasChangeEnvironmentalConditions()) { - ProcessChange(*m_data.GetActions().GetEnvironmentActions().GetChangeEnvironmentalConditions(), m_data.GetSubstances()); + ProcessChange(m_data.GetActions().GetEnvironmentActions().GetChangeEnvironmentalConditions(), m_data.GetSubstances()); m_data.GetActions().GetEnvironmentActions().RemoveChangeEnvironmentalConditions(); } @@ -303,7 +303,7 @@ void Environment::ProcessActions() //We'll allow heating, cooling, and temperature setting to be done simultaneously - SEThermalApplication* ta = m_data.GetActions().GetEnvironmentActions().GetThermalApplication(); + SEThermalApplication& ta = m_data.GetActions().GetEnvironmentActions().GetThermalApplication(); double dEffectiveAreaFraction = 0.0; double dSurfaceArea_m2 = m_data.GetCurrentPatient().GetSkinSurfaceArea(AreaUnit::m2); @@ -312,9 +312,9 @@ void Environment::ProcessActions() double dTotalEffect_W = 0.0; - if (ta->HasActiveHeating()) + if (ta.HasActiveHeating()) { - SEActiveConditioning& ah = ta->GetActiveHeating(); + SEActiveConditioning& ah = ta.GetActiveHeating(); if (ah.HasSurfaceArea() && ah.HasSurfaceAreaFraction()) { ///\error Warning: SurfaceArea and SurfaceAreaFraction are both set. The largest fraction will be used. @@ -351,9 +351,9 @@ void Environment::ProcessActions() } dEffectiveAreaFraction = 0.0; - if (ta->HasActiveCooling()) + if (ta.HasActiveCooling()) { - SEActiveConditioning& ac = ta->GetActiveCooling(); + SEActiveConditioning& ac = ta.GetActiveCooling(); if (ac.HasSurfaceArea() && ac.HasSurfaceAreaFraction()) { ///\error Warning: SurfaceArea and SurfaceAreaFraction are both set. The largest fraction will be used. @@ -395,9 +395,9 @@ void Environment::ProcessActions() //Handle active temperature dEffectiveAreaFraction = 0.0; - if (ta->HasAppliedTemperature()) + if (ta.HasAppliedTemperature()) { - SEAppliedTemperature& ap = ta->GetAppliedTemperature(); + SEAppliedTemperature& ap = ta.GetAppliedTemperature(); if (ap.HasSurfaceArea() && ap.HasSurfaceAreaFraction()) { ///\error Warning: AppliedSurfaceArea and AppliedSurfaceAreaFraction are both set. The largest fraction will be used. diff --git a/src/cpp/cpm/equipment/AnesthesiaMachine.cpp b/src/cpp/cpm/equipment/AnesthesiaMachine.cpp index af0a26f7462f73e5b2799583994877fed3eb1d54..3fe1862ce07762d407d9fe43ae7b47eb8631426f 100644 --- a/src/cpp/cpm/equipment/AnesthesiaMachine.cpp +++ b/src/cpp/cpm/equipment/AnesthesiaMachine.cpp @@ -300,7 +300,7 @@ void AnesthesiaMachine::PreProcess() { if (m_actions->HasAnesthesiaMachineConfiguration()) { - ProcessConfiguration(*m_actions->GetAnesthesiaMachineConfiguration(), m_data.GetSubstances()); + ProcessConfiguration(m_actions->GetAnesthesiaMachineConfiguration(), m_data.GetSubstances()); m_actions->RemoveAnesthesiaMachineConfiguration(); } //Do nothing if the machine is off and not initialized @@ -374,7 +374,7 @@ void AnesthesiaMachine::CalculateScrubber() if (m_actions->HasAnesthesiaMachineSodaLimeFailure()) { - double SodaLimeFailSeverity = m_actions->GetAnesthesiaMachineSodaLimeFailure()->GetSeverity().GetValue(); + double SodaLimeFailSeverity = m_actions->GetAnesthesiaMachineSodaLimeFailure().GetSeverity().GetValue(); CO2Volume = SodaLimeFailSeverity * m_scubberCO2->GetVolume(VolumeUnit::L); } @@ -403,7 +403,7 @@ void AnesthesiaMachine::CalculateGasSourceSubstances() if(m_actions->HasAnesthesiaMachineVaporizerFailure()) { - VaporizerFailureSeverity = m_actions->GetAnesthesiaMachineVaporizerFailure()->GetSeverity().GetValue(); + VaporizerFailureSeverity = m_actions->GetAnesthesiaMachineVaporizerFailure().GetSeverity().GetValue(); } if(GetLeftChamber().GetState() == eSwitch::On && GetLeftChamber().HasSubstance() && GetLeftChamber().HasSubstanceFraction()) { @@ -586,11 +586,11 @@ void AnesthesiaMachine::CalculateEquipmentLeak() if (m_actions->HasAnesthesiaMachineTubeCuffLeak()) { - CuffLeakSeverity = m_actions->GetAnesthesiaMachineTubeCuffLeak()->GetSeverity().GetValue(); + CuffLeakSeverity = m_actions->GetAnesthesiaMachineTubeCuffLeak().GetSeverity().GetValue(); } if (m_actions->HasAnesthesiaMachineYPieceDisconnect()) { - YPieceDisconnectSeverity = m_actions->GetAnesthesiaMachineYPieceDisconnect()->GetSeverity().GetValue(); + YPieceDisconnectSeverity = m_actions->GetAnesthesiaMachineYPieceDisconnect().GetSeverity().GetValue(); } //Combine the severities @@ -614,11 +614,11 @@ void AnesthesiaMachine::CalculateEquipmentLeak() if (m_actions->HasAnesthesiaMachineMaskLeak()) { - MaskLeakSeverity = m_actions->GetAnesthesiaMachineMaskLeak()->GetSeverity().GetValue(); + MaskLeakSeverity = m_actions->GetAnesthesiaMachineMaskLeak().GetSeverity().GetValue(); } if (m_actions->HasAnesthesiaMachineYPieceDisconnect()) { - YPieceDisconnectSeverity = m_actions->GetAnesthesiaMachineYPieceDisconnect()->GetSeverity().GetValue(); + YPieceDisconnectSeverity = m_actions->GetAnesthesiaMachineYPieceDisconnect().GetSeverity().GetValue(); } //Combine the severities @@ -655,23 +655,23 @@ void AnesthesiaMachine::CalculateValveResistances() //Handle leaks and obstructions if (m_actions->HasAnesthesiaMachineInspiratoryValveLeak()) { - double severity = m_actions->GetAnesthesiaMachineInspiratoryValveLeak()->GetSeverity().GetValue(); + double severity = m_actions->GetAnesthesiaMachineInspiratoryValveLeak().GetSeverity().GetValue(); dInspValveOpenResistance = GeneralMath::ExponentialDecayFunction(10.0, dInspValveClosedResistance, dInspValveOpenResistance, severity); } else if (m_actions->HasAnesthesiaMachineInspiratoryValveObstruction()) { - double severity = m_actions->GetAnesthesiaMachineInspiratoryValveObstruction()->GetSeverity().GetValue(); + double severity = m_actions->GetAnesthesiaMachineInspiratoryValveObstruction().GetSeverity().GetValue(); dInspValveClosedResistance = GeneralMath::ExponentialDecayFunction(10.0, dInspValveOpenResistance, dInspValveClosedResistance, severity); } if (m_actions->HasAnesthesiaMachineExpiratoryValveLeak()) { - double severity = m_actions->GetAnesthesiaMachineExpiratoryValveLeak()->GetSeverity().GetValue(); + double severity = m_actions->GetAnesthesiaMachineExpiratoryValveLeak().GetSeverity().GetValue(); dExpValveOpenResistance = GeneralMath::ExponentialDecayFunction(10.0, dExpValveClosedResistance, dExpValveOpenResistance, severity); } else if (m_actions->HasAnesthesiaMachineExpiratoryValveObstruction()) { - double severity = m_actions->GetAnesthesiaMachineExpiratoryValveObstruction()->GetSeverity().GetValue(); + double severity = m_actions->GetAnesthesiaMachineExpiratoryValveObstruction().GetSeverity().GetValue(); dExpValveClosedResistance = GeneralMath::ExponentialDecayFunction(10.0, dExpValveOpenResistance, dExpValveClosedResistance, severity); } @@ -713,7 +713,7 @@ void AnesthesiaMachine::CalculateVentilatorPressure() } if (m_actions->HasAnesthesiaMachineVentilatorPressureLoss()) { - double severity = m_actions->GetAnesthesiaMachineVentilatorPressureLoss()->GetSeverity().GetValue(); + double severity = m_actions->GetAnesthesiaMachineVentilatorPressureLoss().GetSeverity().GetValue(); dDriverPressure *= (1 - severity); } m_pEnvironmentToVentilator->GetNextPressureSource().SetValue(dDriverPressure, PressureUnit::cmH2O); diff --git a/src/cpp/cpm/equipment/Inhaler.cpp b/src/cpp/cpm/equipment/Inhaler.cpp index 9818b82a0f563fca4501035c9ddba0547c085f40..13a368048a54172f0c5b1ee7c5eb9ba8493743e1 100644 --- a/src/cpp/cpm/equipment/Inhaler.cpp +++ b/src/cpp/cpm/equipment/Inhaler.cpp @@ -105,8 +105,8 @@ void Inhaler::PreProcess() if (m_data.GetActions().GetEquipmentActions().HasInhalerConfiguration()) { eSwitch state = GetState(); - SEInhalerConfiguration* config = m_data.GetActions().GetEquipmentActions().GetInhalerConfiguration(); - ProcessConfiguration(*config, m_data.GetSubstances()); + SEInhalerConfiguration& config = m_data.GetActions().GetEquipmentActions().GetInhalerConfiguration(); + ProcessConfiguration(config, m_data.GetSubstances()); m_data.GetActions().GetEquipmentActions().RemoveInhalerConfiguration(); if (state != m_State) { @@ -116,13 +116,13 @@ void Inhaler::PreProcess() } if (m_data.GetActions().GetPatientActions().HasConsciousRespiration()) { - SEConsciousRespiration* cr = m_data.GetActions().GetPatientActions().GetConsciousRespiration(); - SEConsciousRespirationCommand* cmd = cr->GetActiveCommand(); + SEConsciousRespiration& cr = m_data.GetActions().GetPatientActions().GetConsciousRespiration(); + SEConsciousRespirationCommand* cmd = cr.GetActiveCommand(); SEUseInhaler* ui = dynamic_cast(cmd); if (ui != nullptr) { Administer(); - cr->RemoveActiveCommand(); + cr.RemoveActiveCommand(); } } diff --git a/src/cpp/cpm/equipment/MechanicalVentilator.cpp b/src/cpp/cpm/equipment/MechanicalVentilator.cpp index 0d25377386f0e4085c97cb08dd416e700f70467c..33566d1e4fca85c569d2937997ba5fe43ba3b8e2 100644 --- a/src/cpp/cpm/equipment/MechanicalVentilator.cpp +++ b/src/cpp/cpm/equipment/MechanicalVentilator.cpp @@ -301,7 +301,7 @@ void MechanicalVentilator::PreProcess() if (m_data.GetActions().GetEquipmentActions().HasMechanicalVentilatorConfiguration()) { SEMechanicalVentilator::Clear(); - ProcessConfiguration(*m_data.GetActions().GetEquipmentActions().GetMechanicalVentilatorConfiguration(), m_data.GetSubstances()); + ProcessConfiguration(m_data.GetActions().GetEquipmentActions().GetMechanicalVentilatorConfiguration(), m_data.GetSubstances()); m_data.GetActions().GetEquipmentActions().RemoveMechanicalVentilatorConfiguration(); } //Do nothing if the ventilator is off and not initialized diff --git a/src/cpp/cpm/io/protobuf/PBPulsePhysiology.cpp b/src/cpp/cpm/io/protobuf/PBPulsePhysiology.cpp index 32b159c4691d700422b305058c5a53dca0535315..66e4064fe195adf652525dd0126c1826902bf78e 100644 --- a/src/cpp/cpm/io/protobuf/PBPulsePhysiology.cpp +++ b/src/cpp/cpm/io/protobuf/PBPulsePhysiology.cpp @@ -95,33 +95,6 @@ void PBPulsePhysiology::Serialize(const PULSE_BIND::CardiovascularData& src, Car PBProperty::Load(src.cardiaccyclepulmonaryarterypressure_mmhg(), *dst.m_CardiacCyclePulmonaryArteryPressure_mmHg); PBProperty::Load(src.cardiaccyclecentralvenouspressure_mmhg(), *dst.m_CardiacCycleCentralVenousPressure_mmHg); PBProperty::Load(src.cardiaccycleskinflow_ml_per_s(), *dst.m_CardiacCycleSkinFlow_mL_Per_s); - - // As these are dynamically added to the system during run time, - // We will need to make the association within the system here - // Currently, there is no PulseCompartmentManager Load/Unload to do that for us - // It looks for the static cmpt/circuit memebers and adds those to the associated system - // As these were dynamically created, these will not be handled in that code - // (It probably should) - // But, anything that is dynamically created needs to be associated by the System Load - // So we are doing that here. - // Also, Internal Hemorrhage is a subset of Hemorrhage, so internal is associated via - // This regular hemorrhage links/paths getting associated properly - for (auto name : src.hemorrhagelinks()) - { - SELiquidCompartmentLink* hLink = dst.m_data.GetCompartments().GetLiquidLink(name); - dst.m_data.GetCompartments().GetCardiovascularGraph().AddLink(*hLink); - dst.m_HemorrhageLinks.push_back(hLink); - } - if(!dst.m_HemorrhageLinks.empty()) - dst.m_data.GetCompartments().GetCardiovascularGraph().StateChange(); - for (auto name : src.hemorrhagepaths()) - { - SEFluidCircuitPath* hPath = dst.m_data.GetCircuits().GetFluidPath(name); - dst.m_data.GetCircuits().GetCardiovascularCircuit().AddPath(*hPath); - dst.m_HemorrhagePaths.push_back(hPath); - } - if (!dst.m_HemorrhagePaths.empty()) - dst.m_data.GetCircuits().GetCardiovascularCircuit().StateChange(); } PULSE_BIND::CardiovascularData* PBPulsePhysiology::Unload(const Cardiovascular& src) { @@ -166,12 +139,6 @@ void PBPulsePhysiology::Serialize(const Cardiovascular& src, PULSE_BIND::Cardiov dst.set_allocated_cardiaccyclepulmonaryarterypressure_mmhg(PBProperty::Unload(*src.m_CardiacCyclePulmonaryArteryPressure_mmHg)); dst.set_allocated_cardiaccyclecentralvenouspressure_mmhg(PBProperty::Unload(*src.m_CardiacCycleCentralVenousPressure_mmHg)); dst.set_allocated_cardiaccycleskinflow_ml_per_s(PBProperty::Unload(*src.m_CardiacCycleSkinFlow_mL_Per_s)); - - for (auto* l : src.m_HemorrhageLinks) - dst.add_hemorrhagelinks(l->GetName()); - for (auto* p : src.m_HemorrhagePaths) - dst.add_hemorrhagepaths(p->GetName()); - } void PBPulsePhysiology::Load(const PULSE_BIND::DrugData& src, Drugs& dst) diff --git a/src/cpp/cpm/io/protobuf/PBPulseState.cpp b/src/cpp/cpm/io/protobuf/PBPulseState.cpp index efbce888a827f2dead367ac08db1db0f10a70fc0..6dac9ed86e3221298dcddab8d8de686d82f57aed 100644 --- a/src/cpp/cpm/io/protobuf/PBPulseState.cpp +++ b/src/cpp/cpm/io/protobuf/PBPulseState.cpp @@ -141,7 +141,7 @@ bool PBPulseState::Serialize(const PULSE_BIND::StateData& src, PulseController& for (int i = 0; i < src.activeactions().anyaction_size(); i++) { SEAction* a = PBAction::Load(src.activeactions().anyaction()[i], *dst.m_Substances); - dst.m_Actions->ProcessAction(*a, *dst.m_Substances); + dst.m_Actions->ProcessAction(*a); delete a; } } diff --git a/src/cpp/cpm/physiology/Cardiovascular.cpp b/src/cpp/cpm/physiology/Cardiovascular.cpp index c8aef96cdbc2d7a69d02d2a59c547c7ffc67bbc5..8044360a7b8f014c4a4b811ac2f96ae9bb92e4c6 100644 --- a/src/cpp/cpm/physiology/Cardiovascular.cpp +++ b/src/cpp/cpm/physiology/Cardiovascular.cpp @@ -11,7 +11,6 @@ // Conditions #include "engine/SEConditionManager.h" #include "patient/conditions/SEChronicAnemia.h" -#include "patient/conditions/SEChronicHeartFailure.h" #include "patient/conditions/SEChronicPericardialEffusion.h" #include "patient/conditions/SEChronicRenalStenosis.h" // Actions @@ -170,9 +169,7 @@ void Cardiovascular::Clear() m_CardiacCycleCentralVenousPressure_mmHg->Clear(); m_CardiacCycleSkinFlow_mL_Per_s->Clear(); - m_HemorrhageLinks.clear(); - m_HemorrhagePaths.clear(); - + DELETE_MAP_SECOND(m_HemorrhageTrack); } //-------------------------------------------------------------------------------------------------- @@ -267,7 +264,7 @@ void Cardiovascular::Initialize() void Cardiovascular::SetUp() { m_dT_s = m_data.GetTimeStep().GetValue(TimeUnit::s); - m_minIndividialSystemicResistance__mmHg_s_Per_mL = 0.1; + m_minIndividialSystemicResistance_mmHg_s_Per_mL = 0.1; //Circuits m_CirculatoryCircuit = &m_data.GetCircuits().GetActiveCardiovascularCircuit(); @@ -957,8 +954,8 @@ void Cardiovascular::TraumaticBrainInjury() return; //Grab info about the injury - SEBrainInjury* b = m_data.GetActions().GetPatientActions().GetBrainInjury(); - double severity = b->GetSeverity().GetValue(); + SEBrainInjury& b = m_data.GetActions().GetPatientActions().GetBrainInjury(); + double severity = b.GetSeverity().GetValue(); //Interpolate linearly between multipliers of 1 (for severity of 0) to max (for severity of 1) //These multipliers are chosen to result in ICP > 25 mmHg and CBF < 1.8 mL/s @@ -984,86 +981,90 @@ void Cardiovascular::Hemorrhage() //Check all existing hemorrhage paths, if has a flow source or a resistance (covers both types of hemorrhage), then set to zero // - We do not want to assume prior knowledge, so we can ensure we capture the current flow rate or severity // - If zero at the end, we will remove these hemorrhages - for (SEFluidCircuitPath* path : m_HemorrhagePaths) + for (auto itr : m_HemorrhageTrack) { - if(path->HasNextFlowSource()) - path->GetNextFlowSource().SetValue(0.0, VolumePerTimeUnit::mL_Per_s); - if (path->HasNextResistance()) - path->GetNextResistance().SetValue(0.0, PressureTimePerVolumeUnit::mmHg_s_Per_mL); + for (auto itr : itr.second->Paths2Links) + { + SEFluidCircuitPath* path = itr.first; + if (path->HasNextFlowSource()) + path->GetNextFlowSource().SetValue(0.0, VolumePerTimeUnit::mL_Per_s); + if (path->HasNextResistance()) + path->GetNextResistance().SetValue(0.0, PressureTimePerVolumeUnit::mmHg_s_Per_mL); + } } - SEHemorrhage* h; bool completeStateChange = false; double TotalLossRate_mL_Per_s = 0.0; std::vector invalid_hemorrhages; - const std::map & hems = m_data.GetActions().GetPatientActions().GetHemorrhages(); + const std::vector& hems = m_data.GetActions().GetPatientActions().GetHemorrhages(); //Loop over all hemorrhages to check for validity - for (auto hem : hems) + for (auto h : hems) { - h = hem.second; + if (!h->IsActive()) + continue; - // Allow shorthand naming - SELiquidCompartment* compartment = m_data.GetCompartments().GetCardiovascularGraph().GetCompartment(h->GetCompartment()); - //Add Vasculature to the compartment name to grab the cardiovascular compartment - if (compartment == nullptr) + Cardiovascular::HemorrhageTrack* trk; + auto t = m_HemorrhageTrack.find(h); + if (t != m_HemorrhageTrack.end()) { - h->SetCompartment(h->GetCompartment() + "Vasculature"); - compartment = m_data.GetCompartments().GetCardiovascularGraph().GetCompartment(h->GetCompartment()); + trk = t->second; } - //Unsupported compartment - if (compartment == nullptr) + else { - /// \error Error: Removing invalid Hemorrhage due to unsupported compartment - Error("Removing invalid Hemorrhage due to unsupported compartment : " + h->GetCompartment()); - invalid_hemorrhages.push_back(h); - continue; + trk = new Cardiovascular::HemorrhageTrack(); + m_HemorrhageTrack[h] = trk; } - if (!compartment) - { - // \error Error: Bleeding must be from a vascular compartment - Error("Cannot hemorrhage from compartment " + h->GetComment() + ", must be a valid vascular compartment"); - invalid_hemorrhages.push_back(h); - continue; - } - if (h->GetType() == eHemorrhage_Type::Internal) + if (trk->Compartment == nullptr) { - SELiquidCompartment* abdomenCompartment = m_data.GetCompartments().GetLiquidCompartment(pulse::VascularCompartment::Abdomen); - if (!abdomenCompartment->HasChild(compartment->GetName())) + // Allow shorthand naming + trk->Compartment = m_data.GetCompartments().GetCardiovascularGraph().GetCompartment(h->GetCompartment()); + //Add Vasculature to the compartment name to grab the cardiovascular compartment + if (trk->Compartment == nullptr) { - /// \error Error: Internal Hemorrhage is only supported for the abdominal region, including the right and left kidneys, liver, spleen, splanchnic, and small and large intestine vascular compartments. - Error("Internal Hemorrhage is only supported for the abdominal region, including the right and left kidneys, liver, spleen, splanchnic, and small and large intestine vascular compartments."); + trk->Compartment = m_data.GetCompartments().GetCardiovascularGraph().GetCompartment(h->GetCompartment()+"Vasculature"); + } + //Unsupported compartment + if (trk->Compartment == nullptr) + { + /// \error Error: Removing invalid Hemorrhage due to unsupported compartment + Error("Removing invalid Hemorrhage due to unsupported compartment : " + h->GetCompartment()); invalid_hemorrhages.push_back(h); continue; } + if (h->GetType() == eHemorrhage_Type::Internal) + { + SELiquidCompartment* abdomenCompartment = m_data.GetCompartments().GetLiquidCompartment(pulse::VascularCompartment::Abdomen); + if (!abdomenCompartment->HasChild(trk->Compartment->GetName())) + { + /// \error Error: Internal Hemorrhage is only supported for the abdominal region, including the right and left kidneys, liver, spleen, splanchnic, and small and large intestine vascular compartments. + Error("Internal Hemorrhage is only supported for the abdominal region, including the right and left kidneys, liver, spleen, splanchnic, and small and large intestine vascular compartments."); + invalid_hemorrhages.push_back(h); + continue; + } + } } - // \warning Warning: A flow rate and severity were both provided, we will only use the severity. - if (h->HasFlowRate() && h->HasSeverity()) - { - h->GetFlowRate().Invalidate(); - Warning("Hemorrhage requested with both flow rate and severity, we will only use severity."); - } double rate_mL_Per_s = 0; - if (h->HasFlowRate()) + if (h->HasSeverity()) { - rate_mL_Per_s = h->GetFlowRate().GetValue(VolumePerTimeUnit::mL_Per_s); - TotalLossRate_mL_Per_s += rate_mL_Per_s; - if (rate_mL_Per_s < 0) + if (h->GetSeverity().GetValue() < 0.0 || h->GetSeverity().GetValue() > 1.0) { - /// \error Error: Bleeding rate cannot be less than zero - Error("Cannot specify bleeding less than 0"); + /// \error Error: Severity cannot be less than zero or greater than 1.0 + Error("A severity less than 0 or greater than 1.0 cannot be specified."); invalid_hemorrhages.push_back(h); continue; } } - else if (h->HasSeverity()) + else if (h->HasFlowRate()) { - if (h->GetSeverity().GetValue() < 0.0 || h->GetSeverity().GetValue() > 1.0) + rate_mL_Per_s = h->GetFlowRate().GetValue(VolumePerTimeUnit::mL_Per_s); + TotalLossRate_mL_Per_s += rate_mL_Per_s; + if (rate_mL_Per_s < 0) { - /// \error Error: Severity cannot be less than zero or greater than 1.0 - Error("A severity less than 0 or greater than 1.0 cannot be specified."); + /// \error Error: Bleeding rate cannot be less than zero + Error("Cannot specify bleeding less than 0"); invalid_hemorrhages.push_back(h); continue; } @@ -1075,54 +1076,57 @@ void Cardiovascular::Hemorrhage() } //Get all circuit nodes in this compartment - std::vector nodes; - nodes.insert(nodes.end(), compartment->GetNodeMapping().GetNodes().begin(), compartment->GetNodeMapping().GetNodes().end()); - for (unsigned int leafIter = 0; leafIter < compartment->GetLeaves().size(); leafIter++) + if (trk->Nodes.empty()) { - SELiquidCompartment* leaf = compartment->GetLeaves().at(leafIter); - nodes.insert(nodes.end(), leaf->GetNodeMapping().GetNodes().begin(), leaf->GetNodeMapping().GetNodes().end()); - } - - unsigned int nodesIter = 0; - unsigned int nodesWithVolume = 0; - double totalVolume_mL = 0.0; - while (nodesIter < nodes.size()) - { - SEFluidCircuitNode* node = nodes.at(nodesIter); - //Only use nodes that are part of the Circulatory circuit - if (std::find(m_CirculatoryCircuit->GetNodes().begin(), m_CirculatoryCircuit->GetNodes().end(), node) == m_CirculatoryCircuit->GetNodes().end()) + if (trk->Compartment->HasChildren()) { - //Not in circuit - nodes.erase(nodes.begin() + nodesIter); - continue; + for (SELiquidCompartment* leaf : trk->Compartment->GetLeaves()) + { + for (SEFluidCircuitNode* node : leaf->GetNodeMapping().GetNodes()) + { + if (m_CirculatoryCircuit->HasNode(node->GetName())) + { + trk->Nodes.push_back(node); + if (node->HasNextVolume()) + trk->NumNodesWithVolume++; + } + } + } } - - if (node->HasNextVolume()) + else { - nodesWithVolume++; - totalVolume_mL += node->GetNextVolume(VolumeUnit::mL); + for (SEFluidCircuitNode* node : trk->Compartment->GetNodeMapping().GetNodes()) + { + if (m_CirculatoryCircuit->HasNode(node->GetName())) + { + trk->Nodes.push_back(node); + if (node->HasNextVolume()) + trk->NumNodesWithVolume++; + } + } } - nodesIter++; + if (trk->Nodes.empty()) + { + /// \error Error: Hemorrhage compartments must have nodes in the circulatory circuit + Error("Hemorrhage compartments must have nodes in the circulatory circuit"); + invalid_hemorrhages.push_back(h); + continue; + } } - if (nodes.size() == 0) - { - /// \error Error: Hemorrhage compartments must have nodes in the circulatory circuit - Error("Hemorrhage compartments must have nodes in the circulatory circuit"); - invalid_hemorrhages.push_back(h); - continue; - } + // What is the current volume of the compartment? + double totalVolume_mL =trk->Compartment->GetVolume(VolumeUnit::mL); //Update the circuit to remove blood from the specified compartment - for (auto node : nodes) + for (auto node : trk->Nodes) { //Weight the flow sink value by node volume double thisNodeRate_mL_Per_s = 0.0; - if (nodesWithVolume == 0) + if (trk->NumNodesWithVolume == 0) { //No nodes have volume, so evenly distribute - thisNodeRate_mL_Per_s = rate_mL_Per_s / double(nodes.size()); + thisNodeRate_mL_Per_s = rate_mL_Per_s / double(trk->Nodes.size()); } else if (!node->HasNextVolume()) { @@ -1135,38 +1139,23 @@ void Cardiovascular::Hemorrhage() thisNodeRate_mL_Per_s = rate_mL_Per_s * node->GetNextVolume(VolumeUnit::mL) / totalVolume_mL; } - bool calculateResistanceBaseline = false; bool calculateResistance = false; + bool calculateResistanceBaseline = false; //Find the path associated with the node and check if we've already been hemorrhaging here SEFluidCircuitPath* hemorrhagePath = nullptr; - for (unsigned int hIter = 0; hIter < m_HemorrhagePaths.size(); hIter++) + for (auto itr : trk->Paths2Links) { - hemorrhagePath = m_HemorrhagePaths.at(hIter); - if (&(hemorrhagePath->GetSourceNode()) == node) + SEFluidCircuitPath* p = itr.first; + if (&(p->GetSourceNode()) == node) + { + hemorrhagePath = p; break; - hemorrhagePath = nullptr; + } } if (hemorrhagePath != nullptr) { - //Update the existing bleed path - if (h->HasFlowRate()) - { - if (!hemorrhagePath->HasResistanceBaseline()) - { - //Increment value to allow overlapping compartments - hemorrhagePath->GetNextFlowSource().IncrementValue(thisNodeRate_mL_Per_s, VolumePerTimeUnit::mL_Per_s); - } - else - { - hemorrhagePath->GetResistance().Invalidate(); - hemorrhagePath->GetNextResistance().Invalidate(); - hemorrhagePath->GetResistanceBaseline().Invalidate(); - hemorrhagePath->GetNextFlowSource().IncrementValue(thisNodeRate_mL_Per_s, VolumePerTimeUnit::mL_Per_s); - completeStateChange = true; - } - } - else // Severity + if (h->HasSeverity()) // Severity { if (hemorrhagePath->HasFlowSource()) { @@ -1181,37 +1170,60 @@ void Cardiovascular::Hemorrhage() if (h->GetSeverity().GetValue() == 0.0) hemorrhagePath->GetNextResistance().SetValue(0.0, PressureTimePerVolumeUnit::mmHg_min_Per_L); else - { calculateResistance = true; - } + } + } + //Update the existing bleed path + else // Static Flow Rate + { + if (!hemorrhagePath->HasResistanceBaseline()) + { + //Increment value to allow overlapping compartments + hemorrhagePath->GetNextFlowSource().IncrementValue(thisNodeRate_mL_Per_s, VolumePerTimeUnit::mL_Per_s); + } + else + { + hemorrhagePath->GetResistance().Invalidate(); + hemorrhagePath->GetNextResistance().Invalidate(); + hemorrhagePath->GetResistanceBaseline().Invalidate(); + hemorrhagePath->GetNextFlowSource().IncrementValue(thisNodeRate_mL_Per_s, VolumePerTimeUnit::mL_Per_s); + completeStateChange = true; } } } else //new hemorrhage path { //Add bleed path for fluid mechanics - SEFluidCircuitPath* newHemorrhagePath = nullptr; //Check to see if internal or external hemorrhage if (h->GetType() == eHemorrhage_Type::Internal) { - newHemorrhagePath = &m_CirculatoryCircuit->CreatePath(*node, *m_CirculatoryCircuit->GetNode(pulse::CardiovascularNode::AbdominalCavity1), node->GetName() + "InternalHemorrhage"); + hemorrhagePath = &m_CirculatoryCircuit->CreatePath(*node, *m_CirculatoryCircuit->GetNode(pulse::CardiovascularNode::AbdominalCavity1), node->GetName() + "InternalHemorrhage"); } else { - newHemorrhagePath = &m_CirculatoryCircuit->CreatePath(*node, *m_Ground, node->GetName() + "Hemorrhage"); + hemorrhagePath = &m_CirculatoryCircuit->CreatePath(*node, *m_Ground, node->GetName() + "Hemorrhage"); } - if (h->HasFlowRate()) + if(h->HasSeverity()) { - //Increment value to allow overlapping compartments - newHemorrhagePath->GetNextFlowSource().IncrementValue(thisNodeRate_mL_Per_s, VolumePerTimeUnit::mL_Per_s); + if (h->GetSeverity().GetValue() == 0.0) + hemorrhagePath->GetNextResistance().SetValue(0.0, PressureTimePerVolumeUnit::mmHg_min_Per_L); + else + { + if (!hemorrhagePath->HasResistanceBaseline()) + {// If it has a baseline resistance, and our HemorrhageTrack did not have this path + // then I assume that is because this hemorrhage action was loaded from a state + // and this is the first advance time step after theh load + // and in that case, we want to leave the existing resistance baseline alone + calculateResistanceBaseline = true; + } + calculateResistance = true; + } } else { - if (h->GetSeverity().GetValue() == 0.0) - newHemorrhagePath->GetNextResistance().SetValue(0.0, PressureTimePerVolumeUnit::mmHg_min_Per_L); - calculateResistanceBaseline = true; - calculateResistance = true; + //Increment value to allow overlapping compartments + hemorrhagePath->GetNextFlowSource().IncrementValue(thisNodeRate_mL_Per_s, VolumePerTimeUnit::mL_Per_s); } completeStateChange = true; @@ -1219,40 +1231,33 @@ void Cardiovascular::Hemorrhage() //Add bleed link for transport //Find the source compartment (may be a leaf) to make the graph work (i.e., to transport) SELiquidCompartment* sourceCompartment = nullptr; - if (std::find(compartment->GetNodeMapping().GetNodes().begin(), compartment->GetNodeMapping().GetNodes().end(), node) != compartment->GetNodeMapping().GetNodes().end()) - { - sourceCompartment = compartment; - } - else + if (trk->Compartment->HasChildren()) { - for (unsigned int leafIter = 0; leafIter < compartment->GetLeaves().size(); leafIter++) + for (SELiquidCompartment* leaf : trk->Compartment->GetLeaves()) { - SELiquidCompartment* leaf = compartment->GetLeaves().at(leafIter); - if (std::find(leaf->GetNodeMapping().GetNodes().begin(), leaf->GetNodeMapping().GetNodes().end(), node) != leaf->GetNodeMapping().GetNodes().end()) - { + if (leaf->GetNodeMapping().HasMapping(*node)) sourceCompartment = leaf; - break; - } } } - - if (sourceCompartment == nullptr) Fatal("Unable to find the correct source compartment."); + else + { + sourceCompartment = trk->Compartment; + } - SELiquidCompartmentLink& newHemorrhageLink = m_data.GetCompartments().CreateLiquidLink(*sourceCompartment, *m_Groundcmpt, compartment->GetName() + "Hemorrhage"); - newHemorrhageLink.MapPath(*newHemorrhagePath); - m_CirculatoryGraph->AddLink(newHemorrhageLink); + if (sourceCompartment == nullptr) + Fatal("Unable to find the correct source compartment."); - //Add to local lists - m_HemorrhagePaths.push_back(newHemorrhagePath); - m_HemorrhageLinks.push_back(&newHemorrhageLink); + SELiquidCompartmentLink& hemorrhageLink = m_data.GetCompartments().CreateLiquidLink(*sourceCompartment, *m_Groundcmpt, trk->Compartment->GetName() + "Hemorrhage"); + hemorrhageLink.MapPath(*hemorrhagePath); + m_CirculatoryGraph->AddLink(hemorrhageLink); - hemorrhagePath = newHemorrhagePath; + //Add to local lists + trk->Paths2Links[hemorrhagePath] = &hemorrhageLink; } if (calculateResistance) { if (calculateResistanceBaseline) - { // calculate the max flow rate double flowRate_L_per_min = 0; @@ -1278,38 +1283,52 @@ void Cardiovascular::Hemorrhage() TotalLossRate_mL_Per_s += hemorrhagePath->GetNextFlow().GetValue(VolumePerTimeUnit::mL_Per_s); } } + //Info(h->GetCompartment() + " Flow " + std::to_string(hemorrhagePath->GetNextFlow(VolumePerTimeUnit::mL_Per_s))); + //Info(h->GetCompartment() + " Flow Source " + std::to_string(hemorrhagePath->GetNextFlowSource(VolumePerTimeUnit::mL_Per_s))); + // Keep track of bleeding on the action + double hemorrhagePathFlow_mL_Per_s; + if (h->HasSeverity()) + { + hemorrhagePathFlow_mL_Per_s = hemorrhagePath->HasNextFlow() ? hemorrhagePath->GetNextFlow(VolumePerTimeUnit::mL_Per_s) : 0; + h->GetFlowRate().SetValue(hemorrhagePathFlow_mL_Per_s, VolumePerTimeUnit::mL_Per_s); + } + hemorrhagePathFlow_mL_Per_s = h->HasFlowRate() ? h->GetFlowRate(VolumePerTimeUnit::mL_Per_s) : 0; + h->GetTotalBloodLost().IncrementValue(hemorrhagePathFlow_mL_Per_s* m_dT_s, VolumeUnit::mL); } } - // Remove any invalid hemorrhages - for (SEHemorrhage* ih : invalid_hemorrhages) - m_data.GetActions().GetPatientActions().RemoveHemorrhage(ih->GetCompartment()); - - //Remove hemorrhage elements that aren't being used - //Make sure to do this even if no hemorrhage action, since it's needed when removed - unsigned int hIter = 0; - SEFluidCircuitPath* hemorrhagePath = nullptr; - while (hIter < m_HemorrhagePaths.size()) + // Clean up any hemorrhage tracks that are no longer being used + for (auto tItr : m_HemorrhageTrack) { - hemorrhagePath = m_HemorrhagePaths.at(hIter); - if ((hemorrhagePath->HasNextFlowSource() && hemorrhagePath->GetNextFlowSource().IsZero()) || (hemorrhagePath->HasNextResistance() && hemorrhagePath->GetNextResistance().IsZero())) + bool removeItr = false; + for (auto pItr : tItr.second->Paths2Links) { - hemorrhagePath->GetFlowSource().Invalidate(); - hemorrhagePath->GetNextFlowSource().Invalidate(); - hemorrhagePath->GetResistance().Invalidate(); - hemorrhagePath->GetNextResistance().Invalidate(); - hemorrhagePath->GetResistanceBaseline().Invalidate(); - - m_CirculatoryCircuit->RemovePath(*m_HemorrhagePaths.at(hIter)); - m_HemorrhagePaths.erase(m_HemorrhagePaths.begin() + hIter); + SEFluidCircuitPath* p = pItr.first; + if ((p->HasNextFlowSource() && p->GetNextFlowSource().IsZero()) || + (p->HasNextResistance() && p->GetNextResistance().IsZero())) + { + p->GetFlowSource().Invalidate(); + p->GetNextFlowSource().Invalidate(); + p->GetResistance().Invalidate(); + p->GetNextResistance().Invalidate(); + p->GetResistanceBaseline().Invalidate(); - m_CirculatoryGraph->RemoveLink(*m_HemorrhageLinks.at(hIter)); - m_HemorrhageLinks.erase(m_HemorrhageLinks.begin() + hIter); - completeStateChange = true; + m_CirculatoryCircuit->RemovePath(*p); + m_CirculatoryGraph->RemoveLink(*pItr.second); - continue; + removeItr = true; + completeStateChange = true; + } } - hIter++; + if(removeItr) + invalid_hemorrhages.push_back(tItr.first); + } + + for (SEHemorrhage* ih : invalid_hemorrhages) + { + delete m_HemorrhageTrack[ih]; + m_HemorrhageTrack.erase(ih); + m_data.GetActions().GetPatientActions().RemoveHemorrhage(ih->GetCompartment()); } if (completeStateChange) @@ -1362,7 +1381,7 @@ void Cardiovascular::PericardialEffusion() double compliance_mL_Per_mmHg = 0.0; double intrapericardialVolume_mL = m_Pericardium->GetVolume(VolumeUnit::mL); - double effusionRate_mL_Per_s = m_data.GetActions().GetPatientActions().GetPericardialEffusion()->GetEffusionRate().GetValue(VolumePerTimeUnit::mL_Per_s); + double effusionRate_mL_Per_s = m_data.GetActions().GetPatientActions().GetPericardialEffusion().GetEffusionRate().GetValue(VolumePerTimeUnit::mL_Per_s); if (effusionRate_mL_Per_s <= 0.1 && effusionRate_mL_Per_s > 0.0) { //Slow effusion @@ -1431,14 +1450,14 @@ void Cardiovascular::CPR() if (m_data.GetActions().GetPatientActions().HasChestCompressionForceScale()) { Warning("Attempt to start a new compression during a previous compression. Allow more time between compressions or shorten the compression period."); - m_data.GetActions().GetPatientActions().RemoveChestCompression(); + m_data.GetActions().GetPatientActions().RemoveChestCompressionForceScale(); return; } if (m_data.GetActions().GetPatientActions().HasChestCompressionForce()) { Warning("Attempt to switch to explicit force from force scale during CPR compression. CPR actions will be ignored until current compression ends."); - m_data.GetActions().GetPatientActions().RemoveChestCompression(); + m_data.GetActions().GetPatientActions().RemoveChestCompressionForce(); return; } @@ -1455,14 +1474,15 @@ void Cardiovascular::CPR() if (!m_data.GetEvents().IsEventActive(eEvent::CardiacArrest)) { Warning("CPR attempted on beating heart. Action ignored."); - m_data.GetActions().GetPatientActions().RemoveChestCompression(); + m_data.GetActions().GetPatientActions().RemoveChestCompressionForce(); + m_data.GetActions().GetPatientActions().RemoveChestCompressionForceScale(); return; } // Have a new call for a chest compression if (m_data.GetActions().GetPatientActions().HasChestCompressionForceScale()) { - m_CompressionRatio = m_data.GetActions().GetPatientActions().GetChestCompressionForceScale()->GetForceScale().GetValue(); + m_CompressionRatio = m_data.GetActions().GetPatientActions().GetChestCompressionForceScale().GetForceScale().GetValue(); /// \error Warning: CPR compression ratio must be a positive value between 0 and 1 inclusive. if (m_CompressionRatio < 0.0) Warning("CPR compression ratio must be a positive value between 0 and 1 inclusive."); @@ -1471,16 +1491,16 @@ void Cardiovascular::CPR() BLIM(m_CompressionRatio, 0., 1.); // If no period was assigned by the user, then use the default - 0.4s - if (m_data.GetActions().GetPatientActions().GetChestCompressionForceScale()->HasForcePeriod()) + if (m_data.GetActions().GetPatientActions().GetChestCompressionForceScale().HasForcePeriod()) { - m_CompressionPeriod_s = m_data.GetActions().GetPatientActions().GetChestCompressionForceScale()->GetForcePeriod().GetValue(TimeUnit::s); + m_CompressionPeriod_s = m_data.GetActions().GetPatientActions().GetChestCompressionForceScale().GetForcePeriod().GetValue(TimeUnit::s); } else { m_CompressionPeriod_s = 0.4; } - m_data.GetActions().GetPatientActions().RemoveChestCompression(); + m_data.GetActions().GetPatientActions().RemoveChestCompressionForceScale(); } CalculateAndSetCPRcompressionForce(); @@ -1522,7 +1542,7 @@ void Cardiovascular::CalculateAndSetCPRcompressionForce() } else //Explicit force { - compressionForce_N = m_data.GetActions().GetPatientActions().GetChestCompressionForce()->GetForce().GetValue(ForceUnit::N); + compressionForce_N = m_data.GetActions().GetPatientActions().GetChestCompressionForce().GetForce().GetValue(ForceUnit::N); } m_CompressionTime_s += m_dT_s; @@ -1549,7 +1569,7 @@ void Cardiovascular::CalculateAndSetCPRcompressionForce() // The action is removed when the force is set to 0. if (compressionForce_N == 0) - m_data.GetActions().GetPatientActions().RemoveChestCompression(); + m_data.GetActions().GetPatientActions().RemoveChestCompressionForce(); } //-------------------------------------------------------------------------------------------------- @@ -1830,9 +1850,9 @@ void Cardiovascular::MetabolicToneResponse() // Overall reduction in flow resistance in all paths to allow for increased cardiac output with a metabolic rate increase /// \todo Skip over Brain and Myocardium and add arms and legs resistanceNew__mmHg_s_Per_mL *= (1.0 / metabolicMultiplier); - if (resistanceNew__mmHg_s_Per_mL < m_minIndividialSystemicResistance__mmHg_s_Per_mL) + if (resistanceNew__mmHg_s_Per_mL < m_minIndividialSystemicResistance_mmHg_s_Per_mL) { - resistanceNew__mmHg_s_Per_mL = m_minIndividialSystemicResistance__mmHg_s_Per_mL; + resistanceNew__mmHg_s_Per_mL = m_minIndividialSystemicResistance_mmHg_s_Per_mL; } Path->GetNextResistance().SetValue(resistanceNew__mmHg_s_Per_mL, PressureTimePerVolumeUnit::mmHg_s_Per_mL); } @@ -1860,9 +1880,9 @@ void Cardiovascular::AdjustVascularTone() { /// \todo We are treating all systemic resistance paths equally, including the brain. UpdatedResistance_mmHg_s_Per_mL = m_data.GetNervous().GetBaroreceptorResistanceScale().GetValue()*Path->GetResistanceBaseline(PressureTimePerVolumeUnit::mmHg_s_Per_mL); - if (UpdatedResistance_mmHg_s_Per_mL < m_minIndividialSystemicResistance__mmHg_s_Per_mL) + if (UpdatedResistance_mmHg_s_Per_mL < m_minIndividialSystemicResistance_mmHg_s_Per_mL) { - UpdatedResistance_mmHg_s_Per_mL = m_minIndividialSystemicResistance__mmHg_s_Per_mL; + UpdatedResistance_mmHg_s_Per_mL = m_minIndividialSystemicResistance_mmHg_s_Per_mL; } Path->GetNextResistance().SetValue(UpdatedResistance_mmHg_s_Per_mL, PressureTimePerVolumeUnit::mmHg_s_Per_mL); } @@ -1897,9 +1917,9 @@ void Cardiovascular::AdjustVascularTone() continue; UpdatedResistance_mmHg_s_Per_mL = Path->GetNextResistance(PressureTimePerVolumeUnit::mmHg_s_Per_mL); UpdatedResistance_mmHg_s_Per_mL += ResistanceChange * UpdatedResistance_mmHg_s_Per_mL / GetSystemicVascularResistance(PressureTimePerVolumeUnit::mmHg_s_Per_mL); - if (UpdatedResistance_mmHg_s_Per_mL < m_minIndividialSystemicResistance__mmHg_s_Per_mL) + if (UpdatedResistance_mmHg_s_Per_mL < m_minIndividialSystemicResistance_mmHg_s_Per_mL) { - UpdatedResistance_mmHg_s_Per_mL = m_minIndividialSystemicResistance__mmHg_s_Per_mL; + UpdatedResistance_mmHg_s_Per_mL = m_minIndividialSystemicResistance_mmHg_s_Per_mL; } Path->GetNextResistance().SetValue(UpdatedResistance_mmHg_s_Per_mL, PressureTimePerVolumeUnit::mmHg_s_Per_mL); } diff --git a/src/cpp/cpm/physiology/Cardiovascular.h b/src/cpp/cpm/physiology/Cardiovascular.h index adf40ba9524e4365c582472a600b4bbc93812710..1dcfb50febd403768278ce3b8e00891fd0b14966 100644 --- a/src/cpp/cpm/physiology/Cardiovascular.h +++ b/src/cpp/cpm/physiology/Cardiovascular.h @@ -6,6 +6,7 @@ #include "system/physiology/SECardiovascularSystem.h" #include "substance/SESubstanceTransport.h" class SEPatient; +class SEHemorrhage; class SELiquidCompartment; class SEGasCompartment; class SELiquidSubstanceQuantity; @@ -106,9 +107,6 @@ protected: double m_CompressionTime_s; double m_CompressionRatio; double m_CompressionPeriod_s; - //Hemorrhage - std::vector m_HemorrhageLinks; - std::vector m_HemorrhagePaths; // Vitals and Averages double m_CurrentCardiacCycleTime_s; double m_CardiacCycleDiastolicVolume_mL; // Maximum left heart volume for the current cardiac cycle @@ -132,7 +130,17 @@ protected: bool m_TuneCircuit = true; std::string m_TuningFile; - double m_minIndividialSystemicResistance__mmHg_s_Per_mL; + // Hemorrhage + struct HemorrhageTrack + { + SELiquidCompartment* Compartment=nullptr; + std::vector Nodes; + std::map Paths2Links; + short NumNodesWithVolume=0; + }; + std::mapm_HemorrhageTrack; + + double m_minIndividialSystemicResistance_mmHg_s_Per_mL; SEFluidCircuitCalculator* m_circuitCalculator; SELiquidTransporter* m_transporter; diff --git a/src/cpp/cpm/physiology/Drugs.cpp b/src/cpp/cpm/physiology/Drugs.cpp index e1c1a9d3931751873428686e816278a629206cc7..ebd47e09a37c3b48221e2b18e1a155fe5867fe38 100644 --- a/src/cpp/cpm/physiology/Drugs.cpp +++ b/src/cpp/cpm/physiology/Drugs.cpp @@ -186,33 +186,32 @@ void Drugs::ComputeExposedModelParameters() void Drugs::AdministerSubstanceBolus() { //Need to loop over Bolus Dose Objects - const std::map& boluses = m_data.GetActions().GetPatientActions().GetSubstanceBoluses(); + const std::vector& boluses = m_data.GetActions().GetPatientActions().GetSubstanceBoluses(); if (boluses.empty()) return; std::vector completedBolus; - SESubstanceBolus* bolus; const SESubstance* sub; SELiquidSubstanceQuantity* subQ; - SESubstanceBolusState* bolusState; double dose_mL; double concentration_ugPermL; double massIncrement_ug = 0; double administrationTime_s; - for (auto b : boluses) - { - sub = b.first; - bolus = b.second; - bolusState = &bolus->GetState(); - dose_mL = bolus->GetDose().GetValue(VolumeUnit::mL); - if (bolusState->GetAdministeredDose().GetValue(VolumeUnit::mL)>=dose_mL) + for (auto bolus : boluses) + { + if (!bolus->IsActive()) + continue; + + dose_mL = bolus->GetDose(VolumeUnit::mL); + if (bolus->GetAdministeredDose().GetValue(VolumeUnit::mL) >= dose_mL) { // Finished, remove it completedBolus.push_back(&bolus->GetSubstance()); continue; } + sub = &bolus->GetSubstance(); switch (bolus->GetAdminRoute()) { case eSubstanceAdministration_Route::Intraarterial: @@ -226,8 +225,8 @@ void Drugs::AdministerSubstanceBolus() break; default: /// \error Error: Unavailable Administration Route - Error("Unavailable Bolus Administration Route for substance "+b.first->GetName(), "Drugs::AdministerSubstanceBolus"); - completedBolus.push_back(b.first);// Remove it + Error("Unavailable Bolus Administration Route for substance "+sub->GetName(), "Drugs::AdministerSubstanceBolus"); + completedBolus.push_back(sub);// Remove it continue; } @@ -238,12 +237,10 @@ void Drugs::AdministerSubstanceBolus() } administrationTime_s = bolus->GetAdminDuration(TimeUnit::s); concentration_ugPermL = bolus->GetConcentration(MassPerVolumeUnit::ug_Per_mL); - massIncrement_ug = dose_mL*concentration_ugPermL*m_dt_s / administrationTime_s; - bolusState->GetElapsedTime().IncrementValue(m_dt_s, TimeUnit::s); - bolusState->GetAdministeredDose().IncrementValue(massIncrement_ug / concentration_ugPermL,VolumeUnit::mL); - + massIncrement_ug = dose_mL * concentration_ugPermL * m_dt_s / administrationTime_s; subQ->GetMass().IncrementValue(massIncrement_ug, MassUnit::ug); subQ->Balance(BalanceLiquidBy::Mass); + bolus->GetAdministeredDose().IncrementValue(massIncrement_ug / concentration_ugPermL, VolumeUnit::mL); /// \todo Add fluid amount to fluid system } // Remove any bolus that are complete @@ -262,24 +259,24 @@ void Drugs::AdministerSubstanceBolus() //-------------------------------------------------------------------------------------------------- void Drugs::AdministerSubstanceInfusion() { - const std::map& infusions = m_data.GetActions().GetPatientActions().GetSubstanceInfusions(); + const std::vector& infusions = m_data.GetActions().GetPatientActions().GetSubstanceInfusions(); if (infusions.empty()) return; - SESubstanceInfusion* infusion; - SELiquidSubstanceQuantity* subQ; + SELiquidSubstanceQuantity* subQ; double concentration_ug_Per_mL; double rate_mL_Per_s; double massIncrement_ug = 0; - for (auto i : infusions) + for (auto infusion : infusions) { - auto const sub = i.first; - infusion = i.second; + if (!infusion->IsActive()) + continue; + concentration_ug_Per_mL = infusion->GetConcentration().GetValue(MassPerVolumeUnit::ug_Per_mL); rate_mL_Per_s = infusion->GetRate().GetValue(VolumePerTimeUnit::mL_Per_s); massIncrement_ug = rate_mL_Per_s*concentration_ug_Per_mL*m_dt_s; - subQ = m_venaCavaVascular->GetSubstanceQuantity(*sub); + subQ = m_venaCavaVascular->GetSubstanceQuantity(infusion->GetSubstance()); subQ->GetMass().IncrementValue(massIncrement_ug, MassUnit::ug); /// \todo Enforce limits and remove the fatal error /// \error Fatal: Titration administration cannot be negative @@ -308,11 +305,10 @@ void Drugs::AdministerSubstanceInfusion() //-------------------------------------------------------------------------------------------------- void Drugs::AdministerSubstanceCompoundInfusion() { - const std::map& infusions = m_data.GetActions().GetPatientActions().GetSubstanceCompoundInfusions(); + const std::vector& infusions = m_data.GetActions().GetPatientActions().GetSubstanceCompoundInfusions(); if (infusions.empty()) return; - SESubstanceCompoundInfusion* infusion; const SESubstanceCompound* compound; SELiquidSubstanceQuantity* subQ; double rate_mL_Per_s = 0; @@ -323,11 +319,12 @@ void Drugs::AdministerSubstanceCompoundInfusion() std::vector emptyBags; - for(auto i : infusions) + for(auto infusion : infusions) { - compound = i.first; - infusion = i.second; + if (!infusion->IsActive()) + continue; + compound = &infusion->GetSubstanceCompound(); rate_mL_Per_s = infusion->GetRate().GetValue(VolumePerTimeUnit::mL_Per_s); totalRate_mL_Per_s += rate_mL_Per_s; /// \todo Enforce limits and remove the fatal error diff --git a/src/cpp/cpm/physiology/Endocrine.cpp b/src/cpp/cpm/physiology/Endocrine.cpp index f3703b3db1b58c13c6ed017e7c304332ae7e88a6..7c2939dd442c70d39caa6180cf42f3df2a794001 100644 --- a/src/cpp/cpm/physiology/Endocrine.cpp +++ b/src/cpp/cpm/physiology/Endocrine.cpp @@ -163,8 +163,7 @@ void Endocrine::ReleaseEpinephrine() // If we have a stress/anxiety response, release more epi if (m_data.GetActions().GetPatientActions().HasAcuteStress()) { - SEAcuteStress* s = m_data.GetActions().GetPatientActions().GetAcuteStress(); - double severity = s->GetSeverity().GetValue(); + double severity = m_data.GetActions().GetPatientActions().GetAcuteStress().GetSeverity().GetValue(); //The highest stress multiplier we currently support is 30 releaseMultiplier += GeneralMath::LinearInterpolator(0, 1, 0, 30, severity); diff --git a/src/cpp/cpm/physiology/Energy.cpp b/src/cpp/cpm/physiology/Energy.cpp index 2f2ae8b4ab3c28a082dd919e9d9aa4d7aacbd75a..da823276bd41401398a52b4259da6596d3085bbc 100644 --- a/src/cpp/cpm/physiology/Energy.cpp +++ b/src/cpp/cpm/physiology/Energy.cpp @@ -298,9 +298,10 @@ void Energy::Exercise() // Only try to get intensity if the exercise action is active. Otherwise, we are just refilling energy buckets post-exercise. if (m_data.GetActions().GetPatientActions().HasExercise()) { - if (m_data.GetActions().GetPatientActions().GetExercise()->HasIntensity()) + SEExercise& ex = m_data.GetActions().GetPatientActions().GetExercise(); + if (ex.HasIntensity()) { - exerciseIntensity = m_data.GetActions().GetPatientActions().GetExercise()->GetIntensity().GetValue(); + exerciseIntensity = ex.GetIntensity().GetValue(); } else { diff --git a/src/cpp/cpm/physiology/Gastrointestinal.cpp b/src/cpp/cpm/physiology/Gastrointestinal.cpp index 677e30801ef03fbb350736d3e626df4abe3fc8e1..da9d1a803d5d933ee3816c24cbd9e58a5fef4f00 100644 --- a/src/cpp/cpm/physiology/Gastrointestinal.cpp +++ b/src/cpp/cpm/physiology/Gastrointestinal.cpp @@ -160,19 +160,19 @@ void Gastrointestinal::PreProcess() if (m_data.GetActions().GetPatientActions().HasConsumeNutrients()) { // Use Default Rates if none provided - SEConsumeNutrients* c = m_data.GetActions().GetPatientActions().GetConsumeNutrients(); - if (c->HasNutritionFile()) + SEConsumeNutrients& c = m_data.GetActions().GetPatientActions().GetConsumeNutrients(); + if (c.HasNutritionFile()) {// Grab file, then load it (note GetNutrition will remove the file name, so get it first) - std::string file = c->GetNutritionFile(); - if (!c->GetNutrition().SerializeFromFile(file)) + std::string file = c.GetNutritionFile(); + if (!c.GetNutrition().SerializeFromFile(file)) { /// \error Unable to read consume meal action file Error("Could not read provided nutrition file", "Gastrointestinal::PreProcess"); } } - DefaultNutritionRates(c->GetNutrition()); - m_StomachContents->Increment(c->GetNutrition()); - m_data.GetCurrentPatient().GetWeight().IncrementValue(c->GetNutrition().GetWeight(MassUnit::kg), MassUnit::kg); + DefaultNutritionRates(c.GetNutrition()); + m_StomachContents->Increment(c.GetNutrition()); + m_data.GetCurrentPatient().GetWeight().IncrementValue(c.GetNutrition().GetWeight(MassUnit::kg), MassUnit::kg); m_data.GetActions().GetPatientActions().RemoveConsumeNutrients(); } DigestStomachNutrients(m_dT_s); diff --git a/src/cpp/cpm/physiology/Nervous.cpp b/src/cpp/cpm/physiology/Nervous.cpp index 0fe7dc368f00e0c0a36c5a61a196d7a56fbc3cad..c6c518a091c5dc0f4b4b7f29438fdc090f94d3a3 100644 --- a/src/cpp/cpm/physiology/Nervous.cpp +++ b/src/cpp/cpm/physiology/Nervous.cpp @@ -530,25 +530,25 @@ void Nervous::SetPupilEffects() // Calculate the TBI response if (m_data.GetActions().GetPatientActions().HasBrainInjury()) { - SEBrainInjury* b = m_data.GetActions().GetPatientActions().GetBrainInjury(); + SEBrainInjury& b = m_data.GetActions().GetPatientActions().GetBrainInjury(); - if (b->GetSeverity().GetValue() > 0) + if (b.GetSeverity().GetValue() > 0) { double icp_mmHg = m_data.GetCardiovascular().GetIntracranialPressure().GetValue(PressureUnit::mmHg); - if (b->GetType() == eBrainInjury_Type::Diffuse) + if (b.GetType() == eBrainInjury_Type::Diffuse) { leftPupilSizeResponseLevel += (1 / (1 + exp(-2.3*(icp_mmHg - 22.5)))); leftPupilReactivityResponseLevel += -.001*pow(10, .3*(icp_mmHg - 15)); rightPupilSizeResponseLevel = leftPupilSizeResponseLevel; rightPupilReactivityResponseLevel = leftPupilReactivityResponseLevel; } - else if (b->GetType() == eBrainInjury_Type::LeftFocal) + else if (b.GetType() == eBrainInjury_Type::LeftFocal) { leftPupilSizeResponseLevel += (1 / (1 + exp(-2.3*(icp_mmHg - 22.5)))); leftPupilReactivityResponseLevel += -.001*pow(10, .3*(icp_mmHg - 15)); } - else if(b->GetType() == eBrainInjury_Type::RightFocal) + else if(b.GetType() == eBrainInjury_Type::RightFocal) { rightPupilSizeResponseLevel += (1 / (1 + exp(-2.3*(icp_mmHg - 22.5)))); rightPupilReactivityResponseLevel += -.001*pow(10, .3*(icp_mmHg - 15)); diff --git a/src/cpp/cpm/physiology/Respiratory.cpp b/src/cpp/cpm/physiology/Respiratory.cpp index 03402c26e37478fdf54c7549d36f2490424b0a52..df85733ae51afcbe002b42acb06b36deae3c710f 100644 --- a/src/cpp/cpm/physiology/Respiratory.cpp +++ b/src/cpp/cpm/physiology/Respiratory.cpp @@ -824,12 +824,12 @@ void Respiratory::MechanicalVentilation() { if (m_data.GetActions().GetPatientActions().HasMechanicalVentilation()) { - SEMechanicalVentilation* mv = m_data.GetActions().GetPatientActions().GetMechanicalVentilation(); + SEMechanicalVentilation& mv = m_data.GetActions().GetPatientActions().GetMechanicalVentilation(); // You only get here if action is On m_data.SetAirwayMode(eAirwayMode::MechanicalVentilation); //Set the substance volume fractions ******************************************** - std::vector gasFractions = mv->GetGasFractions(); + std::vector gasFractions = mv.GetGasFractions(); //Reset the substance quantities at the connection for (SEGasSubstanceQuantity* subQ : m_MechanicalVentilationConnection->GetSubstanceQuantities()) @@ -861,7 +861,7 @@ void Respiratory::MechanicalVentilation() } //Set the aerosol concentrations ******************************************** - std::vector liquidConcentrations = mv->GetAerosols(); + std::vector liquidConcentrations = mv.GetAerosols(); //Reset the substance quantities at the connection for (SELiquidSubstanceQuantity* subQ : m_MechanicalVentilationAerosolConnection->GetSubstanceQuantities()) @@ -885,9 +885,9 @@ void Respiratory::MechanicalVentilation() } //Apply the instantaneous flow ******************************************** - if (mv->HasFlow()) + if (mv.HasFlow()) { - m_ConnectionToAirway->GetNextFlowSource().Set(mv->GetFlow()); + m_ConnectionToAirway->GetNextFlowSource().Set(mv.GetFlow()); //It may or may not be there if (!m_ConnectionToAirway->HasFlowSource()) { @@ -905,10 +905,10 @@ void Respiratory::MechanicalVentilation() } //Apply the instantaneous pressure ******************************************** - if (mv->HasPressure()) + if (mv.HasPressure()) { //This is the pressure above ambient - m_GroundToConnection->GetNextPressureSource().Set(mv->GetPressure()); + m_GroundToConnection->GetNextPressureSource().Set(mv.GetPressure()); } else { @@ -942,17 +942,17 @@ void Respiratory::SupplementalOxygen() if (!m_data.GetActions().GetPatientActions().HasSupplementalOxygen()) return; - SESupplementalOxygen* so = m_data.GetActions().GetPatientActions().GetSupplementalOxygen(); + SESupplementalOxygen& so = m_data.GetActions().GetPatientActions().GetSupplementalOxygen(); // Get flow double flow_L_Per_min = 0; - if(so->HasFlow()) - flow_L_Per_min = so->GetFlow(VolumePerTimeUnit::L_Per_min); + if(so.HasFlow()) + flow_L_Per_min = so.GetFlow(VolumePerTimeUnit::L_Per_min); //Get tank pressure node and flow control resistor path SEFluidCircuitPath* Tank = nullptr; SEFluidCircuitPath* OxygenInlet = nullptr; SEFluidCircuit* RespirationCircuit = nullptr; - switch (so->GetDevice()) + switch (so.GetDevice()) { case eSupplementalOxygen_Device::None: { @@ -968,10 +968,10 @@ void Respiratory::SupplementalOxygen() m_data.SetAirwayMode(eAirwayMode::Free); m_data.SetAirwayMode(eAirwayMode::NasalCannula); - if (!so->HasFlow()) + if (!so.HasFlow()) { flow_L_Per_min = 3.5; - so->GetFlow().SetValue(flow_L_Per_min, VolumePerTimeUnit::L_Per_min); + so.GetFlow().SetValue(flow_L_Per_min, VolumePerTimeUnit::L_Per_min); Info("Supplemental oxygen flow not set. Using default value of " + cdm::to_string(flow_L_Per_min) + " L/min."); } RespirationCircuit = &m_data.GetCircuits().GetActiveRespiratoryCircuit(); @@ -987,10 +987,10 @@ void Respiratory::SupplementalOxygen() m_data.SetAirwayMode(eAirwayMode::Free); m_data.SetAirwayMode(eAirwayMode::NonRebreatherMask); - if (!so->HasFlow()) + if (!so.HasFlow()) { flow_L_Per_min = 10.0; - so->GetFlow().SetValue(flow_L_Per_min, VolumePerTimeUnit::L_Per_min); + so.GetFlow().SetValue(flow_L_Per_min, VolumePerTimeUnit::L_Per_min); Info("Supplemental oxygen flow not set. Using default value of " + cdm::to_string(flow_L_Per_min) + " L/min."); } RespirationCircuit = &m_data.GetCircuits().GetActiveRespiratoryCircuit(); @@ -1006,10 +1006,10 @@ void Respiratory::SupplementalOxygen() m_data.SetAirwayMode(eAirwayMode::Free); m_data.SetAirwayMode(eAirwayMode::SimpleMask); - if (!so->HasFlow()) + if (!so.HasFlow()) { flow_L_Per_min = 7.5; - so->GetFlow().SetValue(flow_L_Per_min, VolumePerTimeUnit::L_Per_min); + so.GetFlow().SetValue(flow_L_Per_min, VolumePerTimeUnit::L_Per_min); Info("Supplemental oxygen flow not set. Using default value of " + cdm::to_string(flow_L_Per_min) + " L/min."); } RespirationCircuit = &m_data.GetCircuits().GetActiveRespiratoryCircuit(); @@ -1019,27 +1019,27 @@ void Respiratory::SupplementalOxygen() } default: { - Error("Ignoring unsupported supplemental oxygen type : " + eSupplementalOxygen_Device_Name(so->GetDevice())); + Error("Ignoring unsupported supplemental oxygen type : " + eSupplementalOxygen_Device_Name(so.GetDevice())); return; } } //Use a default tank volume if it wasn't explicity set - if (!so->HasVolume()) + if (!so.HasVolume()) { - so->GetVolume().SetValue(425.0, VolumeUnit::L); + so.GetVolume().SetValue(425.0, VolumeUnit::L); Info("Supplemental oxygen initial tank volume not set. Using default value of 425 L."); } //Decrement volume from the tank //Inf volume is assumed to be a wall connection that will never run out - if (so->GetVolume(VolumeUnit::L) != std::numeric_limits::infinity()) + if (so.GetVolume(VolumeUnit::L) != std::numeric_limits::infinity()) { - so->GetVolume().IncrementValue(-flow_L_Per_min * m_dt_min, VolumeUnit::L); + so.GetVolume().IncrementValue(-flow_L_Per_min * m_dt_min, VolumeUnit::L); //Check if the tank is depleated - if (so->GetVolume(VolumeUnit::L) <= 0.0) + if (so.GetVolume(VolumeUnit::L) <= 0.0) { - so->GetVolume().SetValue(0.0, VolumeUnit::L); + so.GetVolume().SetValue(0.0, VolumeUnit::L); flow_L_Per_min = 0.0; /// \event Supplemental Oxygen: Oxygen bottle is exhausted. There is no longer any oxygen to provide. m_data.GetEvents().SetEvent(eEvent::SupplementalOxygenBottleExhausted, true, m_data.GetSimulationTime()); @@ -1051,7 +1051,7 @@ void Respiratory::SupplementalOxygen() m_data.GetEvents().SetEvent(eEvent::SupplementalOxygenBottleExhausted, false, m_data.GetSimulationTime()); //Nonrebreather mask works differently with the bag and doesn't have a pressure source for the tank - if (so->GetDevice() != eSupplementalOxygen_Device::NonRebreatherMask) + if (so.GetDevice() != eSupplementalOxygen_Device::NonRebreatherMask) { //Determine flow control resistance //Assume pressure outside tank is comparatively approximately ambient @@ -1402,11 +1402,11 @@ void Respiratory::RespiratoryDriver() { if (m_ActiveConsciousRespirationCommand) { - SEConsciousRespiration* cr = m_PatientActions->GetConsciousRespiration(); - SEConsciousRespirationCommand* cmd = cr->GetActiveCommand(); + SEConsciousRespiration& cr = m_PatientActions->GetConsciousRespiration(); + SEConsciousRespirationCommand* cmd = cr.GetActiveCommand(); m_ss << "Completed Conscious Respiration Command : " << *cmd; Info(m_ss); - cr->RemoveActiveCommand(); + cr.RemoveActiveCommand(); } } } @@ -1466,7 +1466,7 @@ void Respiratory::Pneumothorax() if (m_PatientActions->HasLeftOpenTensionPneumothorax()) { // Scale the flow resistance through the chest opening based on severity - double severity = m_PatientActions->GetLeftOpenTensionPneumothorax()->GetSeverity().GetValue(); + double severity = m_PatientActions->GetLeftOpenTensionPneumothorax().GetSeverity().GetValue(); double resistance_cmH2O_s_Per_L = PneumoMaxResistance_cmH2O_s_Per_L; if (severity > 0.0 && !m_PatientActions->HasLeftChestOcclusiveDressing()) { @@ -1484,7 +1484,7 @@ void Respiratory::Pneumothorax() if (m_PatientActions->HasRightOpenTensionPneumothorax()) { // Scale the flow resistance through the chest opening based on severity - double severity = m_PatientActions->GetRightOpenTensionPneumothorax()->GetSeverity().GetValue(); + double severity = m_PatientActions->GetRightOpenTensionPneumothorax().GetSeverity().GetValue(); double resistance_cmH2O_s_Per_L = PneumoMaxResistance_cmH2O_s_Per_L; if (severity > 0.0 && !m_PatientActions->HasRightChestOcclusiveDressing()) { @@ -1503,7 +1503,7 @@ void Respiratory::Pneumothorax() if (m_PatientActions->HasLeftClosedTensionPneumothorax()) { // Scale the flow resistance through the chest opening based on severity - double severity = m_PatientActions->GetLeftClosedTensionPneumothorax()->GetSeverity().GetValue(); + double severity = m_PatientActions->GetLeftClosedTensionPneumothorax().GetSeverity().GetValue(); double resistance_cmH2O_s_Per_L = PneumoMaxResistance_cmH2O_s_Per_L; if (severity > 0.0) { @@ -1521,7 +1521,7 @@ void Respiratory::Pneumothorax() if (m_PatientActions->HasRightClosedTensionPneumothorax()) { // Scale the flow resistance through the chest opening based on severity - double severity = m_PatientActions->GetRightClosedTensionPneumothorax()->GetSeverity().GetValue(); + double severity = m_PatientActions->GetRightClosedTensionPneumothorax().GetSeverity().GetValue(); double resistance_cmH2O_s_Per_L = PneumoMaxResistance_cmH2O_s_Per_L; if (severity > 0.0) { @@ -1633,7 +1633,7 @@ void Respiratory::DoRightNeedleDecompression(double dPressureTimePerVolume) //-------------------------------------------------------------------------------------------------- void Respiratory::ConsciousRespiration() { - SEConsciousRespiration* cr = m_PatientActions->GetConsciousRespiration(); + SEConsciousRespiration& cr = m_PatientActions->GetConsciousRespiration(); m_InspiratoryRiseFraction = 0.0; m_InspiratoryHoldFraction = 0.0; @@ -1643,7 +1643,7 @@ void Respiratory::ConsciousRespiration() m_ExpiratoryHoldFraction = 0.0; m_ExpiratoryReleaseFraction = 0.0; - SEConsciousRespirationCommand* cmd = cr->GetActiveCommand(); + SEConsciousRespirationCommand* cmd = cr.GetActiveCommand(); SEForcedInhale* fi = dynamic_cast(cmd); if (fi != nullptr) @@ -2395,8 +2395,8 @@ void Respiratory::UpdateVolumes() double emphysemaSeverity = 0.0; if (m_PatientActions->HasChronicObstructivePulmonaryDiseaseExacerbation()) { - bronchitisSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation()->GetBronchitisSeverity().GetValue(); - emphysemaSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation()->GetEmphysemaSeverity().GetValue(); + bronchitisSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation().GetBronchitisSeverity().GetValue(); + emphysemaSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation().GetEmphysemaSeverity().GetValue(); } else { @@ -2498,8 +2498,8 @@ void Respiratory::UpdateResistances() if (m_PatientActions->HasIntubation()) { m_data.SetIntubation(eSwitch::On); - SEIntubation* intubation = m_PatientActions->GetIntubation(); - switch (intubation->GetType()) + SEIntubation& intubation = m_PatientActions->GetIntubation(); + switch (intubation.GetType()) { case eIntubation_Type::Tracheal: { @@ -2543,7 +2543,7 @@ void Respiratory::UpdateResistances() //Airway obstruction if (m_PatientActions->HasAirwayObstruction()) { - double Severity = m_PatientActions->GetAirwayObstruction()->GetSeverity().GetValue(); + double Severity = m_PatientActions->GetAirwayObstruction().GetSeverity().GetValue(); tracheaResistance_cmH2O_s_Per_L = GeneralMath::ExponentialGrowthFunction(20.0, tracheaResistance_cmH2O_s_Per_L, m_RespOpenResistance_cmH2O_s_Per_L, Severity); tracheaResistance_cmH2O_s_Per_L = MIN(tracheaResistance_cmH2O_s_Per_L, m_RespOpenResistance_cmH2O_s_Per_L); } @@ -2552,7 +2552,7 @@ void Respiratory::UpdateResistances() //Broncho constriction if (m_PatientActions->HasBronchoconstriction()) { - double dSeverity = m_PatientActions->GetBronchoconstriction()->GetSeverity().GetValue(); + double dSeverity = m_PatientActions->GetBronchoconstriction().GetSeverity().GetValue(); leftBronchiResistance_cmH2O_s_Per_L = GeneralMath::ExponentialGrowthFunction(70.0, leftBronchiResistance_cmH2O_s_Per_L, m_RespOpenResistance_cmH2O_s_Per_L, dSeverity); rightBronchiResistance_cmH2O_s_Per_L = GeneralMath::ExponentialGrowthFunction(70.0, rightBronchiResistance_cmH2O_s_Per_L, m_RespOpenResistance_cmH2O_s_Per_L, dSeverity); leftBronchiResistance_cmH2O_s_Per_L = MIN(leftBronchiResistance_cmH2O_s_Per_L, m_RespOpenResistance_cmH2O_s_Per_L); @@ -2599,7 +2599,7 @@ void Respiratory::UpdateResistances() //Asthma if (m_PatientActions->HasAsthmaAttack()) { - double severity = m_PatientActions->GetAsthmaAttack()->GetSeverity().GetValue(); + double severity = m_PatientActions->GetAsthmaAttack().GetSeverity().GetValue(); obstructiveResistanceScalingFactor = GeneralMath::ExponentialGrowthFunction(10.0, 1.0, 90.0, severity); } @@ -2611,7 +2611,7 @@ void Respiratory::UpdateResistances() double bronchitisSeverity = 0.0; if (m_PatientActions->HasChronicObstructivePulmonaryDiseaseExacerbation()) { - bronchitisSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation()->GetBronchitisSeverity().GetValue(); + bronchitisSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation().GetBronchitisSeverity().GetValue(); } else { @@ -2683,7 +2683,7 @@ void Respiratory::UpdateAlveolarCompliances() double emphysemaSeverity = 0.0; if (m_PatientActions->HasChronicObstructivePulmonaryDiseaseExacerbation()) { - emphysemaSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation()->GetEmphysemaSeverity().GetValue(); + emphysemaSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation().GetEmphysemaSeverity().GetValue(); } else { @@ -2711,9 +2711,10 @@ void Respiratory::UpdateAlveolarCompliances() double rightLungFraction = 0.0; if (m_PatientActions->HasLobarPneumoniaExacerbation()) { - severity = m_PatientActions->GetLobarPneumoniaExacerbation()->GetSeverity().GetValue(); - leftLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation()->GetLeftLungAffected().GetValue(); - rightLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation()->GetRightLungAffected().GetValue(); + SELobarPneumoniaExacerbation& lpe = m_PatientActions->GetLobarPneumoniaExacerbation(); + severity = lpe.GetSeverity().GetValue(); + leftLungFraction = lpe.GetLeftLungAffected().GetValue(); + rightLungFraction = lpe.GetRightLungAffected().GetValue(); } else { @@ -2751,9 +2752,10 @@ void Respiratory::UpdateAlveolarCompliances() double rightLungFraction = 0.0; if (m_PatientActions->HasAcuteRespiratoryDistressSyndromeExacerbation()) { - severity = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetSeverity().GetValue(); - leftLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetLeftLungAffected().GetValue(); - rightLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetRightLungAffected().GetValue(); + SEAcuteRespiratoryDistressSyndromeExacerbation& ardse = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation(); + severity = ardse.GetSeverity().GetValue(); + leftLungFraction = ardse.GetLeftLungAffected().GetValue(); + rightLungFraction = ardse.GetRightLungAffected().GetValue(); } else { @@ -2800,7 +2802,7 @@ void Respiratory::UpdateInspiratoryExpiratoryRatio() //Asthma if (m_PatientActions->HasAsthmaAttack()) { - combinedObstructiveSeverity = m_PatientActions->GetAsthmaAttack()->GetSeverity().GetValue(); + combinedObstructiveSeverity = m_PatientActions->GetAsthmaAttack().GetSeverity().GetValue(); } //------------------------------------------------------------------------------------------------------ @@ -2812,8 +2814,8 @@ void Respiratory::UpdateInspiratoryExpiratoryRatio() double emphysemaSeverity = 0.0; if (m_PatientActions->HasChronicObstructivePulmonaryDiseaseExacerbation()) { - bronchitisSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation()->GetBronchitisSeverity().GetValue(); - emphysemaSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation()->GetEmphysemaSeverity().GetValue(); + bronchitisSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation().GetBronchitisSeverity().GetValue(); + emphysemaSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation().GetEmphysemaSeverity().GetValue(); } else { @@ -2838,9 +2840,9 @@ void Respiratory::UpdateInspiratoryExpiratoryRatio() double rightLungFraction = 0.0; if (m_PatientActions->HasLobarPneumoniaExacerbation()) { - severity = m_PatientActions->GetLobarPneumoniaExacerbation()->GetSeverity().GetValue(); - leftLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation()->GetLeftLungAffected().GetValue(); - rightLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation()->GetRightLungAffected().GetValue(); + severity = m_PatientActions->GetLobarPneumoniaExacerbation().GetSeverity().GetValue(); + leftLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation().GetLeftLungAffected().GetValue(); + rightLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation().GetRightLungAffected().GetValue(); } else { @@ -2877,9 +2879,9 @@ void Respiratory::UpdateInspiratoryExpiratoryRatio() double rightLungFraction = 0.0; if (m_PatientActions->HasAcuteRespiratoryDistressSyndromeExacerbation()) { - severity = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetSeverity().GetValue(); - leftLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetLeftLungAffected().GetValue(); - rightLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetRightLungAffected().GetValue(); + severity = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation().GetSeverity().GetValue(); + leftLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation().GetLeftLungAffected().GetValue(); + rightLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation().GetRightLungAffected().GetValue(); } else { @@ -2930,9 +2932,10 @@ void Respiratory::UpdateDiffusion() { if (m_PatientActions->HasImpairedAlveolarExchangeExacerbation()) { - unsigned int total = int(m_PatientActions->GetImpairedAlveolarExchangeExacerbation()->HasImpairedSurfaceArea()) + - int(m_PatientActions->GetImpairedAlveolarExchangeExacerbation()->HasImpairedFraction()) + - int(m_PatientActions->GetImpairedAlveolarExchangeExacerbation()->HasSeverity()); + SEImpairedAlveolarExchangeExacerbation& iaee = m_PatientActions->GetImpairedAlveolarExchangeExacerbation(); + unsigned int total = int(iaee.HasImpairedSurfaceArea()) + + int(iaee.HasImpairedFraction()) + + int(iaee.HasSeverity()); if (total == 0) { @@ -2946,17 +2949,18 @@ void Respiratory::UpdateDiffusion() Warning("The Impaired Alveolar Exchange action is defined with mulitple values. Defaulting to the surface area value first, impaired fraction next, and severity last."); } - if (m_PatientActions->GetImpairedAlveolarExchangeExacerbation()->HasImpairedSurfaceArea()) + if (iaee.HasImpairedSurfaceArea()) { - alveoliDiffusionArea_cm2 = alveoliDiffusionArea_cm2 - m_PatientActions->GetImpairedAlveolarExchangeExacerbation()->GetImpairedSurfaceArea(AreaUnit::cm2); + + alveoliDiffusionArea_cm2 = alveoliDiffusionArea_cm2 - iaee.GetImpairedSurfaceArea(AreaUnit::cm2); } - else if (m_PatientActions->GetImpairedAlveolarExchangeExacerbation()->HasImpairedFraction()) + else if (iaee.HasImpairedFraction()) { - alveoliDiffusionArea_cm2 = (1.0 - m_PatientActions->GetImpairedAlveolarExchangeExacerbation()->GetImpairedFraction().GetValue()) * alveoliDiffusionArea_cm2; + alveoliDiffusionArea_cm2 = (1.0 - iaee.GetImpairedFraction().GetValue()) * alveoliDiffusionArea_cm2; } - else if (m_PatientActions->GetImpairedAlveolarExchangeExacerbation()->HasSeverity()) + else if (iaee.HasSeverity()) { - double severity = m_PatientActions->GetImpairedAlveolarExchangeExacerbation()->GetSeverity().GetValue(); + double severity = iaee.GetSeverity().GetValue(); double gasDiffusionScalingFactor = GeneralMath::ExponentialDecayFunction(10, 0.1, 1.0, severity); alveoliDiffusionArea_cm2 *= gasDiffusionScalingFactor; } @@ -3004,7 +3008,7 @@ void Respiratory::UpdateDiffusion() double emphysemaSeverity = 0.0; if (m_PatientActions->HasChronicObstructivePulmonaryDiseaseExacerbation()) { - emphysemaSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation()->GetEmphysemaSeverity().GetValue(); + emphysemaSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation().GetEmphysemaSeverity().GetValue(); } else { @@ -3027,9 +3031,9 @@ void Respiratory::UpdateDiffusion() double rightLungFraction = 0.0; if (m_PatientActions->HasLobarPneumoniaExacerbation()) { - severity = m_PatientActions->GetLobarPneumoniaExacerbation()->GetSeverity().GetValue(); - leftLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation()->GetLeftLungAffected().GetValue(); - rightLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation()->GetRightLungAffected().GetValue(); + severity = m_PatientActions->GetLobarPneumoniaExacerbation().GetSeverity().GetValue(); + leftLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation().GetLeftLungAffected().GetValue(); + rightLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation().GetRightLungAffected().GetValue(); } else { @@ -3075,9 +3079,9 @@ void Respiratory::UpdateDiffusion() double rightLungFraction = 0.0; if (m_PatientActions->HasAcuteRespiratoryDistressSyndromeExacerbation()) { - severity = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetSeverity().GetValue(); - leftLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetLeftLungAffected().GetValue(); - rightLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetRightLungAffected().GetValue(); + severity = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation().GetSeverity().GetValue(); + leftLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation().GetLeftLungAffected().GetValue(); + rightLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation().GetRightLungAffected().GetValue(); } else { @@ -3123,8 +3127,8 @@ void Respiratory::UpdatePulmonaryCapillary() double emphysemaSeverity = 0.0; if (m_PatientActions->HasChronicObstructivePulmonaryDiseaseExacerbation()) { - bronchitisSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation()->GetBronchitisSeverity().GetValue(); - emphysemaSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation()->GetEmphysemaSeverity().GetValue(); + bronchitisSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation().GetBronchitisSeverity().GetValue(); + emphysemaSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation().GetEmphysemaSeverity().GetValue(); } else { @@ -3195,7 +3199,7 @@ void Respiratory::UpdatePulmonaryShunt() double severity = 0.0; if (m_PatientActions->HasPulmonaryShuntExacerbation()) { - severity = m_PatientActions->GetPulmonaryShuntExacerbation()->GetSeverity().GetValue(); + severity = m_PatientActions->GetPulmonaryShuntExacerbation().GetSeverity().GetValue(); } else { @@ -3216,9 +3220,9 @@ void Respiratory::UpdatePulmonaryShunt() double rightLungFraction = 0.0; if (m_PatientActions->HasLobarPneumoniaExacerbation()) { - severity = m_PatientActions->GetLobarPneumoniaExacerbation()->GetSeverity().GetValue(); - leftLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation()->GetLeftLungAffected().GetValue(); - rightLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation()->GetRightLungAffected().GetValue(); + severity = m_PatientActions->GetLobarPneumoniaExacerbation().GetSeverity().GetValue(); + leftLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation().GetLeftLungAffected().GetValue(); + rightLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation().GetRightLungAffected().GetValue(); } else { @@ -3244,9 +3248,9 @@ void Respiratory::UpdatePulmonaryShunt() double rightLungFraction = 0.0; if (m_PatientActions->HasAcuteRespiratoryDistressSyndromeExacerbation()) { - severity = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetSeverity().GetValue(); - leftLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetLeftLungAffected().GetValue(); - rightLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetRightLungAffected().GetValue(); + severity = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation().GetSeverity().GetValue(); + leftLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation().GetLeftLungAffected().GetValue(); + rightLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation().GetRightLungAffected().GetValue(); } else { @@ -3291,14 +3295,14 @@ void Respiratory::ModifyDriverPressure() //Dyspnea if (m_PatientActions->HasDyspnea()) { - dyspneaSeverity = m_PatientActions->GetDyspnea()->GetSeverity().GetValue(); + dyspneaSeverity = m_PatientActions->GetDyspnea().GetSeverity().GetValue(); } //------------------------------------------------------------------------------------------------------ //Fatigue if (m_PatientActions->HasRespiratoryFatigue()) { - double thisDyspneaSeverity = m_PatientActions->GetRespiratoryFatigue()->GetSeverity().GetValue(); + double thisDyspneaSeverity = m_PatientActions->GetRespiratoryFatigue().GetSeverity().GetValue(); dyspneaSeverity = MAX(dyspneaSeverity, thisDyspneaSeverity); } @@ -3311,8 +3315,8 @@ void Respiratory::ModifyDriverPressure() double emphysemaSeverity = 0.0; if (m_PatientActions->HasChronicObstructivePulmonaryDiseaseExacerbation()) { - bronchitisSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation()->GetBronchitisSeverity().GetValue(); - emphysemaSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation()->GetEmphysemaSeverity().GetValue(); + bronchitisSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation().GetBronchitisSeverity().GetValue(); + emphysemaSeverity = m_PatientActions->GetChronicObstructivePulmonaryDiseaseExacerbation().GetEmphysemaSeverity().GetValue(); } else { @@ -3339,9 +3343,9 @@ void Respiratory::ModifyDriverPressure() double rightLungFraction = 0.0; if (m_PatientActions->HasLobarPneumoniaExacerbation()) { - severity = m_PatientActions->GetLobarPneumoniaExacerbation()->GetSeverity().GetValue(); - leftLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation()->GetLeftLungAffected().GetValue(); - rightLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation()->GetRightLungAffected().GetValue(); + severity = m_PatientActions->GetLobarPneumoniaExacerbation().GetSeverity().GetValue(); + leftLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation().GetLeftLungAffected().GetValue(); + rightLungFraction = m_PatientActions->GetLobarPneumoniaExacerbation().GetRightLungAffected().GetValue(); } else { @@ -3384,9 +3388,9 @@ void Respiratory::ModifyDriverPressure() double rightLungFraction = 0.0; if (m_PatientActions->HasAcuteRespiratoryDistressSyndromeExacerbation()) { - severity = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetSeverity().GetValue(); - leftLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetLeftLungAffected().GetValue(); - rightLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation()->GetRightLungAffected().GetValue(); + severity = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation().GetSeverity().GetValue(); + leftLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation().GetLeftLungAffected().GetValue(); + rightLungFraction = m_PatientActions->GetAcuteRespiratoryDistressSyndromeExacerbation().GetRightLungAffected().GetValue(); } else { diff --git a/src/cpp/howto/HowTo-AnesthesiaMachine.cpp b/src/cpp/howto/HowTo-AnesthesiaMachine.cpp index 4ff834976176777def2b772db650be551f38c514..ab4ccc9f117cc4dd316ae4a5e916104bbc8526e2 100644 --- a/src/cpp/howto/HowTo-AnesthesiaMachine.cpp +++ b/src/cpp/howto/HowTo-AnesthesiaMachine.cpp @@ -187,7 +187,7 @@ void HowToAnesthesiaMachine() tracker.AdvanceModelTime(60); SEAnesthesiaMachineOxygenWallPortPressureLoss AMpressureloss; - AMpressureloss.SetActive(true); + AMpressureloss.SetState(eSwitch::On); pe->ProcessAction(AMpressureloss); pe->GetLogger()->Info("Testing the oxygen pressure loss failure mode. The oxygen pressure from the wall source is dropping."); @@ -201,7 +201,7 @@ void HowToAnesthesiaMachine() pe->GetLogger()->Info(std::stringstream() <<"Respiration Rate : " << pe->GetRespiratorySystem()->GetRespirationRate(FrequencyUnit::Per_min) << "bpm"); pe->GetLogger()->Info(std::stringstream() <<"Oxygen Saturation : " << pe->GetBloodChemistrySystem()->GetOxygenSaturation()); - AMpressureloss.SetActive(false); + AMpressureloss.SetState(eSwitch::On); pe->ProcessAction(AMpressureloss); pe->GetLogger()->Info("Removing the wall oxygen pressure loss action."); diff --git a/src/cpp/howto/HowTo-CombatMultitrauma.cpp b/src/cpp/howto/HowTo-CombatMultitrauma.cpp index 48b1527515d64e7e4df8187c8091500e711eca27..1807879f374da216e1da38f91c0a91fd54789b92 100644 --- a/src/cpp/howto/HowTo-CombatMultitrauma.cpp +++ b/src/cpp/howto/HowTo-CombatMultitrauma.cpp @@ -175,7 +175,7 @@ void LoadState() // Needle Decompression to help with pneumothorax SENeedleDecompression needleDecomp; - needleDecomp.SetActive(true); + needleDecomp.SetState(eSwitch::On); needleDecomp.SetSide(eSide::Left); pe->ProcessAction(needleDecomp); diff --git a/src/cpp/howto/HowTo-Hemorrhage.cpp b/src/cpp/howto/HowTo-Hemorrhage.cpp index 14313c21dee7d798da8e8e0cdec35d3a0ec2456b..df7e0503dc4c4070f872e2070269a233fa040662 100644 --- a/src/cpp/howto/HowTo-Hemorrhage.cpp +++ b/src/cpp/howto/HowTo-Hemorrhage.cpp @@ -6,6 +6,8 @@ // Include the various types you will be using in your code #include "engine/SEDataRequestManager.h" #include "engine/SEEngineTracker.h" +#include "engine/SEActionManager.h" +#include "engine/SEPatientActionCollection.h" #include "compartment/SECompartmentManager.h" #include "patient/actions/SEHemorrhage.h" #include "patient/actions/SESubstanceCompoundInfusion.h" @@ -58,8 +60,12 @@ void HowToHemorrhage() pe->GetEngineTracker()->GetDataRequestManager().CreatePhysiologyDataRequest("SystolicArterialPressure", PressureUnit::mmHg); pe->GetEngineTracker()->GetDataRequestManager().CreatePhysiologyDataRequest("DiastolicArterialPressure", PressureUnit::mmHg); pe->GetEngineTracker()->GetDataRequestManager().CreatePhysiologyDataRequest("HemoglobinContent",MassUnit::g); + pe->GetEngineTracker()->GetDataRequestManager().CreatePhysiologyDataRequest("TotalHemorrhageRate", VolumePerTimeUnit::mL_Per_s); + pe->GetEngineTracker()->GetDataRequestManager().CreatePhysiologyDataRequest("TotalHemorrhagedVolume", VolumeUnit::mL); + pe->GetEngineTracker()->GetDataRequestManager().CreateActionCompartmentDataRequest("Hemorrhage", pulse::VascularCompartment::RightLeg, "FlowRate", VolumePerTimeUnit::mL_Per_s); + pe->GetEngineTracker()->GetDataRequestManager().CreateActionCompartmentDataRequest("Hemorrhage", pulse::VascularCompartment::RightLeg, "TotalBloodLost", VolumeUnit::mL); - pe->GetEngineTracker()->GetDataRequestManager().SetResultsFilename("HowToHemorrhage.csv"); + pe->GetEngineTracker()->GetDataRequestManager().SetResultsFilename("./test_results/HowToHemorrhage.csv"); pe->GetLogger()->Info("The patient is nice and healthy"); pe->GetLogger()->Info(std::stringstream() <<"Cardiac Output : " << pe->GetCardiovascularSystem()->GetCardiacOutput(VolumePerTimeUnit::mL_Per_min) << VolumePerTimeUnit::mL_Per_min); @@ -69,6 +75,8 @@ void HowToHemorrhage() pe->GetLogger()->Info(std::stringstream() <<"Systolic Pressure : " << pe->GetCardiovascularSystem()->GetSystolicArterialPressure(PressureUnit::mmHg) << PressureUnit::mmHg); pe->GetLogger()->Info(std::stringstream() <<"Diastolic Pressure : " << pe->GetCardiovascularSystem()->GetDiastolicArterialPressure(PressureUnit::mmHg) << PressureUnit::mmHg); pe->GetLogger()->Info(std::stringstream() <<"Heart Rate : " << pe->GetCardiovascularSystem()->GetHeartRate(FrequencyUnit::Per_min) << "bpm"); + pe->GetLogger()->Info(std::stringstream() << "Total Hemorrhage Rate : " << pe->GetCardiovascularSystem()->GetTotalHemorrhageRate(VolumePerTimeUnit::mL_Per_s) << "mL/s"); + pe->GetLogger()->Info(std::stringstream() << "Total Hemorrhaged Volume : " << pe->GetCardiovascularSystem()->GetTotalHemorrhagedVolume(VolumeUnit::mL) << "mL"); // Hemorrhage Starts - instantiate a hemorrhage action and have the engine process it SEHemorrhage hemorrhageLeg; @@ -89,6 +97,13 @@ void HowToHemorrhage() return; } + // You can get the current flow rate based on the severity, as well as the total blood lost from each hemorrhage via the action in the action manager + // Note this is a copy of hemorrhageLeg internal to the engine + auto hemorrhages = pe->GetActionManager().GetPatientActions().GetHemorrhages(); + for (auto h : hemorrhages) + std::cout << *h << "\n"; + + pe->GetLogger()->Info("The patient has been hemorrhaging for 300s"); pe->GetLogger()->Info(std::stringstream() <<"Cardiac Output : " << pe->GetCardiovascularSystem()->GetCardiacOutput(VolumePerTimeUnit::mL_Per_min) << VolumePerTimeUnit::mL_Per_min); pe->GetLogger()->Info(std::stringstream() <<"Hemoglobin Content : " << pe->GetBloodChemistrySystem()->GetHemoglobinContent(MassUnit::g) << MassUnit::g); @@ -97,10 +112,17 @@ void HowToHemorrhage() pe->GetLogger()->Info(std::stringstream() <<"Systolic Pressure : " << pe->GetCardiovascularSystem()->GetSystolicArterialPressure(PressureUnit::mmHg) << PressureUnit::mmHg); pe->GetLogger()->Info(std::stringstream() <<"Diastolic Pressure : " << pe->GetCardiovascularSystem()->GetDiastolicArterialPressure(PressureUnit::mmHg) << PressureUnit::mmHg); pe->GetLogger()->Info(std::stringstream() <<"Heart Rate : " << pe->GetCardiovascularSystem()->GetHeartRate(FrequencyUnit::Per_min) << "bpm"); + pe->GetLogger()->Info(std::stringstream() << "Total Hemorrhage Rate : " << pe->GetCardiovascularSystem()->GetTotalHemorrhageRate(VolumePerTimeUnit::mL_Per_s) << "mL/s"); + pe->GetLogger()->Info(std::stringstream() << "Total Hemorrhaged Volume : " << pe->GetCardiovascularSystem()->GetTotalHemorrhagedVolume(VolumeUnit::mL) << "mL"); // Hemorrhage is sealed hemorrhageLeg.SetType(eHemorrhage_Type::External); hemorrhageLeg.SetCompartment(pulse::VascularCompartment::RightLeg);//location of hemorrhage + //hemorrhageLeg.GetSeverity().SetValue(0.);// Stop the hemorrhage + // You can switch between severity and flow if you want, + // But you will need to invalidate the severity for the flow to be used + // If provided both severity and flow, Pulse will use the severity + hemorrhageLeg.GetSeverity().Invalidate(); hemorrhageLeg.GetFlowRate().SetValue(0,VolumePerTimeUnit::mL_Per_min);//rate is set to 0 to close the bleed pe->ProcessAction(hemorrhageLeg); @@ -120,6 +142,8 @@ void HowToHemorrhage() pe->GetLogger()->Info(std::stringstream() <<"Systolic Pressure : " << pe->GetCardiovascularSystem()->GetSystolicArterialPressure(PressureUnit::mmHg) << PressureUnit::mmHg); pe->GetLogger()->Info(std::stringstream() <<"Diastolic Pressure : " << pe->GetCardiovascularSystem()->GetDiastolicArterialPressure(PressureUnit::mmHg) << PressureUnit::mmHg); pe->GetLogger()->Info(std::stringstream() <<"Heart Rate : " << pe->GetCardiovascularSystem()->GetHeartRate(FrequencyUnit::Per_min) << "bpm"); + pe->GetLogger()->Info(std::stringstream() << "Total Hemorrhage Rate : " << pe->GetCardiovascularSystem()->GetTotalHemorrhageRate(VolumePerTimeUnit::mL_Per_s) << "mL/s"); + pe->GetLogger()->Info(std::stringstream() << "Total Hemorrhaged Volume : " << pe->GetCardiovascularSystem()->GetTotalHemorrhagedVolume(VolumeUnit::mL) << "mL"); // Patient is stabilizing, but not great @@ -144,5 +168,7 @@ void HowToHemorrhage() pe->GetLogger()->Info(std::stringstream() <<"Systolic Pressure : " << pe->GetCardiovascularSystem()->GetSystolicArterialPressure(PressureUnit::mmHg) << PressureUnit::mmHg); pe->GetLogger()->Info(std::stringstream() <<"Diastolic Pressure : " << pe->GetCardiovascularSystem()->GetDiastolicArterialPressure(PressureUnit::mmHg) << PressureUnit::mmHg); pe->GetLogger()->Info(std::stringstream() <<"Heart Rate : " << pe->GetCardiovascularSystem()->GetHeartRate(FrequencyUnit::Per_min) << "bpm"); + pe->GetLogger()->Info(std::stringstream() << "Total Hemorrhage Rate : " << pe->GetCardiovascularSystem()->GetTotalHemorrhageRate(VolumePerTimeUnit::mL_Per_s) << "mL/s"); + pe->GetLogger()->Info(std::stringstream() << "Total Hemorrhaged Volume : " << pe->GetCardiovascularSystem()->GetTotalHemorrhagedVolume(VolumeUnit::mL) << "mL"); pe->GetLogger()->Info("Finished"); } diff --git a/src/cpp/howto/HowTo-TensionPneumothorax.cpp b/src/cpp/howto/HowTo-TensionPneumothorax.cpp index c92cb7919a0657474ecc2e791a32fc02db9ce344..5ed8fc09090670e8fcc9b6d4449306b0237f4eef 100644 --- a/src/cpp/howto/HowTo-TensionPneumothorax.cpp +++ b/src/cpp/howto/HowTo-TensionPneumothorax.cpp @@ -102,13 +102,13 @@ void HowToTensionPneumothorax() SENeedleDecompression needleDecomp; // You can turn it off when you would like to remove the intervention - needleDecomp.SetActive(false); + needleDecomp.SetState(eSwitch::Off); // It can be on the Left or right side (it's a good idea to do it on the side of the pneumothorax ;) needleDecomp.SetSide(eSide::Right); //needleDecomp.SetSide(CDM::enumSide::Left); - needleDecomp.SetActive(true); + needleDecomp.SetState(eSwitch::On); pe->ProcessAction(needleDecomp); pe->GetLogger()->Info("Giving the patient a needle decompression"); diff --git a/src/csharp/howto/HowTo_EngineUse.cs b/src/csharp/howto/HowTo_EngineUse.cs index 042bc23576fe843dc6eb15986ca88604935abd8f..8eb2627801bbe14aa8821b6ac7cb012aef10cdf6 100644 --- a/src/csharp/howto/HowTo_EngineUse.cs +++ b/src/csharp/howto/HowTo_EngineUse.cs @@ -52,6 +52,11 @@ namespace HowTo_UseEngine SEDataRequest.CreateGasCompartmentSubstanceRequest("Carina", "CarbonDioxide", "PartialPressure", "mmHg"), SEDataRequest.CreatePhysiologyRequest("BloodVolume", "mL"), SEDataRequest.CreateECGRequest("Lead3ElectricPotential", "mV"), + SEDataRequest.CreateLiquidCompartmentSubstanceRequest("BrainVasculature", "Oxygen", "PartialPressure", "mmHg"), + SEDataRequest.CreateLiquidCompartmentSubstanceRequest("BrainVasculature", "CarbonDioxide", "PartialPressure", "mmHg"), + SEDataRequest.CreateLiquidCompartmentSubstanceRequest("MyocardiumVasculature", "Oxygen", "PartialPressure", "mmHg"), + SEDataRequest.CreateLiquidCompartmentSubstanceRequest("MyocardiumVasculature", "CarbonDioxide", "PartialPressure", "mmHg"), + SEDataRequest.CreateSubstanceRequest("Hemoglobin", "BloodConcentration", "g/dL"), }; SEDataRequestManager data_mgr = new SEDataRequestManager(data_requests); // In addition to getting this data back via this API diff --git a/src/schema/pulse/cdm/bind/Engine.proto b/src/schema/pulse/cdm/bind/Engine.proto index 60255cbd885415bede9d4e2e55f56570b37a58f9..d8720e94b216773c1af82653141ff2eb696bfb2c 100644 --- a/src/schema/pulse/cdm/bind/Engine.proto +++ b/src/schema/pulse/cdm/bind/Engine.proto @@ -35,23 +35,25 @@ message DataRequestData Patient = 0; Physiology = 1; Environment = 2; - GasCompartment = 3; - LiquidCompartment = 4; - ThermalCompartment = 5; - TissueCompartment = 6; - Substance = 7; - AnesthesiaMachine = 8; - ECG = 9; - Inhaler = 10; - MechanicalVentilator = 11; + Action = 3; + GasCompartment = 4; + LiquidCompartment = 5; + ThermalCompartment = 6; + TissueCompartment = 7; + Substance = 8; + AnesthesiaMachine = 9; + ECG = 10; + Inhaler = 11; + MechanicalVentilator = 12; } DecimalFormatData DecimalFormat = 1;/**<<@brief If writing to a file, specify the decimal formatting */ eCategory Category = 2;/**<<@brief A category assocated with the Name */ - string CompartmentName = 3;/**<<@brief The compartment name the property could be associated with */ - string SubstanceName = 4;/**<<@brief The substance name the property could be associated with */ - string PropertyName = 5;/**<<@brief The name of the property requested */ - string Unit = 6;/**<<@brief If writing to a file, the unit the data will be in. */ + string ActionName = 3;/**<<@brief The action name the property is on */ + string CompartmentName = 4;/**<<@brief The compartment name the property could be associated with */ + string SubstanceName = 5;/**<<@brief The substance name the property could be associated with */ + string PropertyName = 6;/**<<@brief The name of the property requested */ + string Unit = 7;/**<<@brief If writing to a file, the unit the data will be in. */ } message DataRequestManagerData { diff --git a/src/schema/pulse/cdm/bind/PatientActions.proto b/src/schema/pulse/cdm/bind/PatientActions.proto index 450c93aa5ea429ec253fd47db06f65142aa7c708..89a923611e2efb9687cdbc220eea156b8bc32701 100644 --- a/src/schema/pulse/cdm/bind/PatientActions.proto +++ b/src/schema/pulse/cdm/bind/PatientActions.proto @@ -229,15 +229,19 @@ message HemorrhageData External = 0; /**<< @brief A loss of blood from the vascular system out of the body */ Internal = 1; /**<< @brief A loss of blood from the vascular system into a body cavity or space. */ } + /** The intended usage of this action is: + * - Severity has precidence over FlowRate (if both provided, use Severity) + * - Setting FlowRate will make the hemorrhage flow constant + * - Flow will be set by the engine, when using a Severity + * - Total Blood Lost is only set by the engine (user cannot set) + */ PatientActionData PatientAction = 1; eType Type = 2;/**<<@brief @ref HemorrhageData_eTypeTable*/ string Compartment = 3;/**<<@brief Compartment where the bleeding is occurring */ - oneof Value - { - ScalarVolumePerTimeData FlowRate = 4;/**<<@brief The flow rate of blood exiting the specified compartment. Set to zero to stop the bleeding rate. */ - Scalar0To1Data Severity = 5;/**<<@brief Scale of affect, 0 being none, 1 being the highest possible. */ - } + ScalarVolumePerTimeData FlowRate = 4;/**<<@brief The flow rate of blood exiting the specified compartment. Set to zero to stop the bleeding rate. */ + Scalar0To1Data Severity = 5;/**<<@brief Scale of affect, 0 being none, 1 being the highest possible. */ + ScalarVolumeData TotalBloodLost = 6;/**<<@brief Total blood lost from this hemorrhage. */ } /** @brief Generic way to specify the effectivness of alveolar exchange. */ @@ -317,12 +321,6 @@ message RespiratoryFatigueData Scalar0To1Data Severity = 2;/**<<@brief Scale of affect, 0 no dyspnea, 1 having dyspnea. */ } -message SubstanceBolusStateData -{ - string Substance = 1;/**<<@brief @ref SubstanceTable */ - ScalarTimeData ElapsedTime = 2;/**<<@brief Amount of time the bolus has been active. */ - ScalarVolumeData AdministeredDose = 3;/**<<@brief Current dose amount administered. */ -} /** @brief An administration of a substance that is given all at one time to raise its concentration in blood to an effective level. */ message SubstanceBolusData { @@ -347,7 +345,6 @@ message SubstanceBolusData ScalarTimeData AdministrationDuration = 4;/**<<@brief Length of time taken to fully administer the bolus. */ ScalarMassPerVolumeData Concentration = 5;/**<<@brief Concentration of the dose to administer. */ ScalarVolumeData Dose = 6;/**<<@brief Volume of dose to administer. */ - SubstanceBolusStateData State = 7;/**<<@brief Current state of the bolus. */ } /** @brief Continuous injection of a compound. */ diff --git a/src/schema/pulse/cpm/bind/PulsePhysiology.proto b/src/schema/pulse/cpm/bind/PulsePhysiology.proto index 34d3d8c83c3ff4a8ee8a36b8d4d9358a7279fc73..d19a6a553e3d1b9cc35240df5e055698540765f0 100644 --- a/src/schema/pulse/cpm/bind/PulsePhysiology.proto +++ b/src/schema/pulse/cpm/bind/PulsePhysiology.proto @@ -52,9 +52,6 @@ message CardiovascularData pulse.cdm.bind.RunningAverageData CardiacCyclePulmonaryArteryPressure_mmHg = 30; pulse.cdm.bind.RunningAverageData CardiacCycleCentralVenousPressure_mmHg = 31; pulse.cdm.bind.RunningAverageData CardiacCycleSkinFlow_mL_Per_s = 32; - - repeated string HemorrhageLinks = 33; - repeated string HemorrhagePaths = 34; } message DrugData