12 Commits

Author SHA1 Message Date
google-labs-jules[bot] fb0962ff95 feat: Implement major physiological feedback loops
This commit re-implements several critical physiological feedback loops that were lost, enhancing the realism of the simulation.

The following systems have been added:

1.  **Full Digestive Loop:**
    - The Gallbladder now has a `releaseBile` method, triggered by chyme in the intestines.
    - The Pancreas has a `releaseEnzymes` method, also triggered by chyme.
    - The Intestines' digestion logic has been updated to be more effective when bile and enzymes are present.

2.  **Autonomic Nervous System Control:**
    - The Brain now monitors blood gas (O2/CO2) and blood pressure levels.
    - It dynamically adjusts the respiration rate of the Lungs via a new `setRespirationRate` method in response to blood gas changes.
    - It controls the heart rate via a new `setHeartRate` method in response to blood pressure changes, simulating the baroreceptor reflex.
    - The previous hardcoded rate control logic in the Lungs and Heart has been removed.

3.  **Kidney Blood Pressure Regulation (RAAS):**
    - A simplified Renin-Angiotensin-Aldosterone System has been implemented.
    - The Kidneys now secrete renin in response to low blood pressure.
    - The Liver produces a constant supply of angiotensinogen.
    - A new `angiotensin_au` value in the Blood struct is calculated in the main patient update loop.
    - This hormone now acts as a vasoconstrictor, directly affecting the blood pressure calculation in the Heart.

These changes significantly increase the complexity and fidelity of the medical simulation by modeling the interconnectedness of the major organ systems.
2025-08-20 08:55:54 +00:00
google-labs-jules[bot] ede2dee772 Feat: Implement interconnected organ simulation
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.
2025-08-20 08:30:53 +00:00
google-labs-jules[bot] 7459435e25 feat: Add detailed simulation to remaining simple organs
This commit applies a detailed physiological model to all remaining simple organ classes, bringing them to a level of complexity consistent with the Heart, Lungs, and Brain.

Updates include:
- Esophagus: Simulates peristalsis and bolus movement.
- Stomach: Implements a gastric state machine for digestion.
- Intestines: Adds segments (duodenum, jejunum, etc.) and simulates absorption.
- Pancreas: Differentiates endocrine and exocrine functions.
- Gallbladder: Simulates storing, concentrating, and releasing bile.
- Kidneys: Models nephrons, GFR, and electrolyte balance.
- Bladder: Implements a micturition cycle with pressure dynamics.
- Spleen: Models red and white pulp for blood filtering and immunity.
2025-08-20 07:11:44 +00:00
google-labs-jules[bot] 278ef9fe8e feat: Add detailed simulation to Lungs and Brain
Applied the level of detail from the Heart simulation to the Lungs and Brain classes.

For the Lungs:
- Added anatomical structures for lobes and bronchi.
- Implemented a respiratory cycle with inspiration/expiration states.
- Simulated tidal volume, airway pressures, and gas exchange.
- Generated a capnography (etCO2) waveform.

For the Brain:
- Added structures for major brain regions.
- Simulated intracranial pressure (ICP) and cerebral perfusion pressure (CPP).
- Implemented a simplified Glasgow Coma Scale (GCS).
- Generated a basic EEG waveform.
2025-08-20 06:34:43 +00:00
google-labs-jules[bot] dbe8490cb1 feat: Implement detailed mechanical heart simulation
This commit introduces a major enhancement to the heart simulation, adding a detailed mechanical model of the cardiac cycle that is synchronized with the existing EKG waveform.

Key features:
- The Heart class is refactored to include data structures for the four chambers (atria and ventricles) and four valves (mitral, tricuspid, aortic, pulmonary).
- The `update` method now simulates the phases of the cardiac cycle, including atrial and ventricular systole and diastole.
- Chamber pressures and volumes are dynamically updated based on the phase of the cycle.
- Valve statuses (open/closed) are determined by pressure gradients between chambers.
- Ejection Fraction is now calculated based on the simulated end-diastolic and end-systolic volumes of the left ventricle.
- The example program has been updated to display a live, detailed summary of the heart's mechanical status, showing pressures, volumes, and valve states as they change over time.
2025-08-20 06:22:24 +00:00
google-labs-jules[bot] c3432e4178 This commit enhances the Patient class by adding several helper functions to improve access to organ data.
- Adds `getOrganSummary` and `getPatientSummary` to retrieve human-readable string summaries of organ vitals.
- Adds a templated function `getOrgan<T>` which allows for type-safe, direct access to specific organ objects. This enables calling organ-specific methods to retrieve raw data values (e.g., `heart->getHeartRate()`).

The example `main.cpp` has been updated to demonstrate the usage of all new functions.
2025-08-20 02:11:03 +00:00
google-labs-jules[bot] 279abdd723 feat: Implement digestive, urinary, and other major organ systems
This commit significantly expands the patient simulation by adding models
for the full digestive and urinary systems, as well as the spleen and
spinal cord.

This builds on the polymorphic organ framework by adding 9 new organ
classes:
- Kidneys
- Bladder
- Stomach
- Intestines
- Gallbladder
- Pancreas
- Esophagus
- Spleen
- SpinalCord

Each new organ has its own header, a source file with simplified
simulation logic for its unique physiological properties, and is
integrated into the main patient model and simulation loop.

The build system and example application have been updated to include
and demonstrate this new, more comprehensive set of organs.
2025-08-20 00:57:05 +00:00
google-labs-jules[bot] bfa583d574 feat: Add Doxygen documentation and Gitea workflow
This commit introduces Doxygen for documentation generation and a Gitea
workflow for continuous integration.

- Adds a `Doxyfile` to configure Doxygen to build a documentation
  website with diagrams.
- Updates `AGENTS.md` to require Doxygen-compatible comments for all
  code.
- Adds Doxygen comments to existing C++ source files to comply with
  the new standard.
- Creates a Gitea workflow (`.gitea/workflows/build.yml`) that:
  - Builds the project on every push.
  - Generates Doxygen documentation.
  - Uploads the compiled library and the documentation website as
    artifacts.
2025-08-18 09:56:29 +00:00
google-labs-jules[bot] 5a79cc45cd feat: Refactor Patient and implement mean-reverting simulation
- Broke out the Patient struct and its related functions (initializePatient, updatePatient) into their own files (Patient.h, Patient.cpp) for better organization.

- Implemented the initial UpdateState logic in the updatePatient function using a mean-reverting model. This ensures that vital signs fluctuate realistically around a healthy baseline.

- Updated CMakeLists.txt to include the new Patient.cpp file in the build.
2025-08-18 09:33:33 +00:00
google-labs-jules[bot] d0d42e10fe feat: Implement initial medical simulation
This commit introduces the initial framework for a medical simulation library.

It adds a `Patient` struct to hold vital signs, including:
- Blood Pressure (Systolic and Diastolic)
- Heart Rate
- Respiration Rate
- Body Temperature
- Oxygen Saturation

It also includes:
- An `initializePatient` function to create a patient with baseline healthy vitals.
- A placeholder `updatePatient` function for future simulation logic.
- An updated example to demonstrate the new functionality.
2025-08-18 09:12:21 +00:00
google-labs-jules[bot] 518277356a Rename the project from "MyLibrary" to "MedicalLib" to better reflect its intended purpose as a library for medical simulations.
- Rename all files, directories, and internal project names to "MedicalLib".
- Replace the generic `add` function with a more domain-specific `calculateBMI` function as an initial example of the library's capabilities.
- Update the `AGENTS.md` file to describe the new purpose and scope of the MedicalLib library.
2025-08-18 09:02:01 +00:00
google-labs-jules[bot] 3b29526b9e Add build scripts and update .gitignore
This commit introduces build scripts for both Windows (`build.bat`) and Linux/macOS (`build.sh`) to simplify the build process.

It also updates the `.gitignore` file to a more comprehensive version that includes common patterns for C++ projects and various IDEs.
2025-08-18 08:15:49 +00:00