31a0b8a485
Multi-Platform CI / test-platforms (ubuntu-22.04) (push) Successful in 18s
Multi-Platform CI / test-platforms (windows-latest) (push) Successful in 18s
Multi-Platform CI / Package for Linux x86_64 (push) Has been skipped
Multi-Platform CI / Package for Windows x86_64 (push) Has been skipped
Multi-Platform CI / Create GitHub Release (push) Has been skipped
- add C FFI enums MLBladderPhase, MLMetabolicState, MLPerfusionState - add C FFI structs MLBloodstreamMetrics and MLBladderMetrics - add ml_patient_bloodstream_metrics and ml_patient_bladder_metrics to populate metrics for a patient (mirrored in src/ffi.rs) - update examples/c/ffi_example.c to print new metrics - add tests for FFI metrics (tests/ffi.rs) organ model expansions - bloodstream: add metrics() snapshot and detailed physiology: plasma proteins/oncotic pressure, lymph return, RBC cohort tracking, erythropoiesis/clearance with HIF, iron/folate/B12 stores, platelets, coagulation/fibrinolysis, immune cell counts, complement, acid–base - bladder: introduce adaptive compliance, reflex gating, cortical/voluntary modulators, safety indices; add metrics(), summary, and unit tests - brain: add homeostatic drives (respiratory, thirst, hunger, thermo, pain), brainstem nuclei (NTS/RVLM/CVLM, nAmb/DMV, RTN), sleep cycle timing, cerebrovascular autoregulation; wire drives into autonomic control - heart: add phase-based cycle (valves and atria), conduction system, RAAS regulation, improved coronary perfusion - intestines: add micronutrient absorption feeding erythropoiesis patient coupling - expose Patient::bloodstream_metrics() and ::bladder_metrics() - integrate new organ signals (kidney osmolality, spleen culling, liver proteins) and brain–lung/continence control pathways - re-export BladderMetrics and BloodstreamMetrics in lib.rs note - existing FFI remains compatible; this is a surface addition - ffi/medicallib.h kept in sync with src/ffi.rs
51 lines
1.7 KiB
C
51 lines
1.7 KiB
C
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include "../../ffi/medicallib.h"
|
|
|
|
int main(void) {
|
|
float bmi = 0.0f;
|
|
if (medicallib_bmi(70.0f, 1.75f, &bmi) != ML_OK) {
|
|
fprintf(stderr, "BMI error\n");
|
|
return 1;
|
|
}
|
|
printf("BMI: %.2f\n", bmi);
|
|
|
|
MLPatient* p = ml_patient_new("ffi-01");
|
|
if (!p) { fprintf(stderr, "patient new failed\n"); return 1; }
|
|
ml_patient_update(p, 0.5f);
|
|
|
|
char* sum = ml_patient_summary(p);
|
|
if (sum) { printf("%s\n", sum); ml_string_free(sum); }
|
|
|
|
MLBloodstreamMetrics blood = {0};
|
|
if (ml_patient_bloodstream_metrics(p, &blood) == ML_OK) {
|
|
printf("Bloodstream: perfusion=%u metabolic=%u oncotic=%.1f mmHg lymph=%.2f mL/min RBC young/mature/senescent=%.0f/%.0f/%.0f%% hif=%.2f iron=%.0f mg\n",
|
|
(unsigned)blood.perfusion_state,
|
|
(unsigned)blood.metabolic_state,
|
|
blood.oncotic_pressure_mm_hg,
|
|
blood.lymphatic_return_ml_min,
|
|
blood.rbc_young_fraction * 100.0f,
|
|
blood.rbc_mature_fraction * 100.0f,
|
|
blood.rbc_senescent_fraction * 100.0f,
|
|
blood.hif_activation,
|
|
blood.iron_store_mg);
|
|
}
|
|
|
|
MLBladderMetrics bladder = {0};
|
|
if (ml_patient_bladder_metrics(p, &bladder) == ML_OK) {
|
|
printf("Bladder: phase=%u urgency=%.0f%% guard=%.0f%% hold=%.0f%%\n",
|
|
(unsigned)bladder.phase,
|
|
bladder.urgency * 100.0f,
|
|
bladder.guarding_reflex_gain * 100.0f,
|
|
bladder.voluntary_hold_fraction * 100.0f);
|
|
}
|
|
|
|
char* h = ml_patient_organ_summary(p, ML_ORGAN_HEART);
|
|
if (h) { printf("%s\n", h); ml_string_free(h); }
|
|
|
|
ml_patient_free(p);
|
|
return 0;
|
|
}
|
|
|
|
|