ede2dee772
This commit refactors the organ simulation to enable dynamic interactions between organs, replacing the previous "faked" or hardcoded connections.
Key changes include:
- Major Refactoring: Changed the `Organ::update` method signature to `update(Patient& patient, double deltaTime_s)`, allowing organs to access the shared patient state and other organs. This was propagated to all organ classes.
- Blood Chemistry Model: Introduced a central `Blood` struct in the `Patient` model to track shared resources like oxygen, CO2, glucose, and toxins.
- Organ System Interconnections:
- Lungs & Brain: Lungs now perform gas exchange affecting the blood. The brain consumes O2, produces CO2, and its GCS is affected by hypoxia/hypercapnia.
- Liver-Gallbladder: Gallbladder now receives bile directly from the liver's production rate.
- Digestive System: Stomach passes chyme to the intestines, which absorb glucose into the blood. The pancreas responds to blood glucose changes.
- Renal System: Kidneys' GFR is now influenced by the heart's aortic pressure, and they produce urine that fills the bladder directly.
- Cardiovascular & Neurological: The heart rate responds to hypoxia, and the brain uses live aortic pressure from the heart.
- Comprehensive Test Scenario: Updated the main example to include a 60-second simulation with a meal and a lung injury event to verify the new interconnected system.
This creates a more realistic and scalable physiological simulation framework where organ behaviors are emergent from their interactions.
66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
// Forward-declare to avoid circular dependency
|
|
struct Patient;
|
|
|
|
// Define MEDICAL_LIB_EXPORT for exporting symbols from the DLL
|
|
#if defined(_WIN32)
|
|
#if defined(MEDICAL_LIB_EXPORT)
|
|
#define MEDICAL_LIB_API __declspec(dllexport)
|
|
#else
|
|
#define MEDICAL_LIB_API __declspec(dllimport)
|
|
#endif
|
|
#else
|
|
#define MEDICAL_LIB_API
|
|
#endif
|
|
|
|
/**
|
|
* @brief Abstract base class for all organ types.
|
|
*/
|
|
class MEDICAL_LIB_API Organ {
|
|
public:
|
|
/**
|
|
* @brief Constructor for the Organ class.
|
|
* @param id The ID of the organ.
|
|
* @param type The type of the organ as a string.
|
|
*/
|
|
Organ(int id, const std::string& type);
|
|
|
|
/**
|
|
* @brief Virtual destructor.
|
|
*/
|
|
virtual ~Organ() = default;
|
|
|
|
/**
|
|
* @brief Pure virtual function to update the organ's state over time.
|
|
* @param patient A reference to the patient object for inter-organ communication.
|
|
* @param deltaTime_s The time elapsed in seconds.
|
|
*/
|
|
virtual void update(Patient& patient, double deltaTime_s) = 0;
|
|
|
|
/**
|
|
* @brief Pure virtual function to get a string summary of the organ's vitals.
|
|
* @return A string containing the organ's vital signs.
|
|
*/
|
|
virtual std::string getSummary() const = 0;
|
|
|
|
/**
|
|
* @brief Gets the organ ID.
|
|
* @return The organ ID.
|
|
*/
|
|
int getId() const;
|
|
|
|
/**
|
|
* @brief Gets the organ type.
|
|
* @return The organ type as a string.
|
|
*/
|
|
const std::string& getType() const;
|
|
|
|
protected:
|
|
int organId;
|
|
std::string organType;
|
|
};
|