October 2, 2016 : Development of the Allowable Blood Loss Theory
© 安岡喜晴 (JoyShine)
Finally, I finished developing the Allowable Blood Loss Theory for the
Medical Calculator.
The core function takes patient type (adult man/woman, infant, premature or full-term neonate), weight, initial HCT, and lowest allowable HCT, estimates blood volume, and returns the maximum allowable blood loss.
static const CalcInput ABL_INPUTS[] = {
{ L"Patient type", INPUT_CHOICE, L"- Select -|Adult Man|Adult Woman|Infant|Premature Neonate|Full Term Neonate" },
{ L"Enter Weight", INPUT_NUMBER, NULL },
{ L"Weight unit", INPUT_CHOICE, L"- Select -|lbs|kg" },
{ L"Enter Patient's Initial HCT (%)", INPUT_NUMBER, NULL },
{ L"Enter Patient's Allowable Lowest HCT (%)", INPUT_NUMBER, NULL },
};
inline void calc_allowable_blood_loss(const double* in,
wchar_t* disp, size_t dsz,
wchar_t* pri, size_t psz,
wchar_t* det, size_t esz) {
int pt, wu;
if (!val_choice(in[0], 5, &pt) || !val_choice(in[2], 2, &wu)) {
calc_err(disp, dsz, pri, psz, det, esz,
L"Patient type must be 1-5; weight unit must be 1 (lbs) or 2 (kg).");
return;
}
if (pt == 0 || wu == 0) {
calc_err(disp, dsz, pri, psz, det, esz,
L"Patient type 0 and weight-unit 0 are reserved sentinels — pick a defined option.");
return;
}
double weight = in[1];
double hct_i = in[3], hct_l = in[4];
if (!val_pos(weight) || !val_pos(hct_i) || !val_nonneg(hct_l) || hct_l > hct_i) {
calc_err(disp, dsz, pri, psz, det, esz,
L"Weight and initial HCT must be > 0; lowest HCT must be >= 0 and not exceed initial HCT.");
return;
}
double avg_bv;
const wchar_t* pt_label;
switch (pt) {
case 1: avg_bv = 75; pt_label = L"Adult Man"; break;
case 2: avg_bv = 65; pt_label = L"Adult Woman"; break;
case 3: avg_bv = 80; pt_label = L"Infant"; break;
case 4: avg_bv = 95; pt_label = L"Premature Neonate"; break;
case 5: avg_bv = 85; pt_label = L"Full Term Neonate"; break;
default: avg_bv = 70; pt_label = L"(unknown)";
}
double w_kg = (wu == 1) ? (weight * 0.45359237) : weight;
double ebv = w_kg * avg_bv;
double abl = ebv * (hct_i - hct_l) / hct_i;
double hmean = (hct_i + hct_l) / 2.0;
double abl_gross = ebv * (hct_i - hct_l) / hmean;
wchar_t b[32], bg[32], be[32];
fmt_g(b, 32, abl); fmt_g(bg, 32, abl_gross); fmt_g(be, 32, ebv);
swprintf(disp, dsz, L"%ls", b);
swprintf(pri, psz,
L"Allowable Blood Loss (Simple) : %ls mL\r\n"
L"Allowable Blood Loss (Gross, mean-Hct) : %ls mL\r\n"
L"Estimated Blood Volume : %ls mL\r\n"
L"Patient type : %ls (avg BV = %g mL/kg)\r\n"
L"Simple = EBV*(Hi-Hf)/Hi; Gross divides by mean Hct = (Hi+Hf)/2 (preferred for larger drops, equivalent at small drops).",
b, bg, be, pt_label, avg_bv);
(void)esz; det[0] = 0;
}